Not sure how to do this.
Simple example would be say I have a JTabbedPane with a JPanel object on
it. How do I drop\replace this JPanel to load a newer modified one while
running.?
Based on what I am doing, on the JPanel, I have no problem dynamically
building the JPanels. Just not sure how to replace the JPanel that
resides on the JTabbedPane.
I really do not want to remove and then insert one of the indexed tabs
to just load a new JPanel on it.

Signature
Thanks in Advance...
IchBin
__________________________________________________________________________
'The meeting of two personalities is like the contact of two chemical
substances: if there is any reaction, both are transformed.'
- Carl Gustav Jung, (1875-1961), psychiatrist and psychologist
Rhino - 13 Feb 2005 16:19 GMT
> Not sure how to do this.
>
[quoted text clipped - 8 lines]
> I really do not want to remove and then insert one of the indexed tabs
> to just load a new JPanel on it.
Assuming your JPanel was instantiated as follows:
JPanel myPanel = ....
All you need to do is:
JPanel myNewPanel = ....
myPanel = myNewPanel;
Rhino
Babu Kalakrishnan - 14 Feb 2005 06:16 GMT
>>Not sure how to do this.
>>
[quoted text clipped - 17 lines]
> JPanel myNewPanel = ....
> myPanel = myNewPanel;
That's a big fallacy.
What you suggested would make the reference "myPanel" to point to the
new JPanel, but will not change the JTabbedPane change the contents of
the tab which held myPanel earlier to display the new panel. (That's
what the OP wanted - if I understood the question correctly)
The basic issue here is understanding the difference between objects and
references. You need to understand that when you call
tabbedpane.addTab("SomeName",myPanel), what is added to the JTabbedPane
is *not* the reference "myPanel", but the JPanel object that myPanel is
pointing to at that moment. Once you have done this, changing the value
of myPanel to anything (even null) is not going to make any difference
to what is inside the JTabbedPane.
To the OP :
You could use the setComponentAt(int,Component) method to set the
Component at a specific index to a new Component. If you don't know the
index - but only the name of the tab, you could always get it using the
method indexOfTab.
BK
Bill Tschumy - 13 Feb 2005 19:10 GMT
> Not sure how to do this.
>
[quoted text clipped - 8 lines]
> I really do not want to remove and then insert one of the indexed tabs
> to just load a new JPanel on it.
myTabbedPane.remove(indexToReplace);
myTabbedPane.add(newPanel, indexToReplace);

Signature
Bill Tschumy
Otherwise -- Austin, TX
http://www.otherwise.com