Who can explain a referencing detail?

I have the following code which adds a JPanel named analysePanel to a JTabbedPane (plotsPane). The "analysePanel" is newly initiated at every iteration and another JPanel is added to it.

for (int i = 0; i < tabDescription.length; i++){

JPanel p1 =new JPanel();

p1.add(new JLabel(tabDescription[i]+" Analyse"));

analysePanel =new EmptyAnalysePanel();

analysePanel.setLayout(new BorderLayout());

analysePanel.add(p1);

plotsPane.add(tabDescription[i],analysePanel);

}

Now why do the Tabs in the tabbedPane contain different panels (that's obviously what I want in the end but I wonder why it is so) and not all the same? Why don't they all have a reference to "analysePanel and display the same thing, the current configuration of "analysePanel?

[1087 byte] By [tango1383a] at [2007-11-27 6:09:09]
# 1
Because plotsPane.add keeps a reference to the panel that you add. It doesn't matter what you do with your reference after that.Kaj
kajbja at 2007-7-12 17:12:36 > top of Java-index,Java Essentials,Java Programming...
# 2
Because you create a new instance for every iteration. If you are referring to the same "analysePanel" you should not create a new instance every time.
jakain2a at 2007-7-12 17:12:36 > top of Java-index,Java Essentials,Java Programming...