Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2005

Tip: Looking for answers? Try searching our database.

Switching a panel wthin a JTabbedPane

Thread view: 
IchBin - 21 Feb 2005 07:53 GMT
I am having a hard time replacing the content of a JPanel by another
one. Can't seem to see the JPanel that replaces the older JPanel within
a JTabbedPane. I am dynamically building a JPanel based on different
data requirements. Not sure what I am doing wrong. .updateUI() does not
show the new JPanel.

Simplified here is the main idea:

*Class_A*
    protected  static JPanel    dummyPanel_A;

    detailTabbedPane.addTab("Tab Title", null, new
JScrollPane(dummyPanel_A),"Tab Tip");

*Class_B*
protected  static JPanel    dummyPanel_B;

Make changes to dummyPanel_B then want to replace the Class_A panel
dummyPanel_A with dummyPanel_B (using Goodies Forms)

 Class_A.dummyPanel = builder.getPanel();
 Class_A.detailTabbedPane.updateUI();

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

Roland - 21 Feb 2005 08:33 GMT
> I am having a hard time replacing the content of a JPanel by another
> one. Can't seem to see the JPanel that replaces the older JPanel within
[quoted text clipped - 18 lines]
>  Class_A.dummyPanel = builder.getPanel();
>  Class_A.detailTabbedPane.updateUI();

Method updateUI() is supposed to be used when the look&feel of a
component has changed. Instead try Class_A.detailTabbedPane.revalidate();

Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \

IchBin - 22 Feb 2005 21:28 GMT
>> I am having a hard time replacing the content of a JPanel by another
>> one. Can't seem to see the JPanel that replaces the older JPanel
[quoted text clipped - 21 lines]
> Method updateUI() is supposed to be used when the look&feel of a
> component has changed. Instead try Class_A.detailTabbedPane.revalidate();

The .revalidate() is not working. Can not understand it. I tried again
(below). Why can't I do say in Class_B:
*SelectedtabbedPane.dummyPanel_A = dummyPanel_B*

----------------------

 *Class_A*
 protected  static JPanel    dummyPanel_A;

 detailTabbedPane.addTab("Tab Title", null, new
 JScrollPane(dummyPanel_A),"Tab Tip");

... upon user tab Selection in Class_A
 Class_B.retrieveIPInformation(someString,SelectedtabbedPane,dummyPanel_A)

*Class_B*
Make changes to dummyPanel_B then want to replace the Class_A panel
dummyPanel_A with dummyPanel_B in SelectedtabbedPane (using Goodies Forms)

protected  static JPanel    dummyPanel_B;

static void retrieveIPInformation(String insomeString,JTabbedPane
SelectedtabbedPane,dummyPanel_A )

..... Build the dummyPanel_B

  dummyPanel_B = builder.getPanel();

..... Switch the dummyPanel_A

  dummyPanel_A = dummyPanel_B;
..... or
  Class_A.dummyPanel_A = dummyPanel_B;

  SelectedtabbedPane.revalidate();

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

IchBin - 23 Feb 2005 01:01 GMT
I guess my question is:

How can you update a JPanel that is embedded within a JScrollPane within
a JTabbedPane object from a different Class? Reflection? I am at a lost
to resolve with out a redesign.

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

Bill Tschumy - 23 Feb 2005 02:50 GMT
> I guess my question is:
>
> How can you update a JPanel that is embedded within a JScrollPane within
> a JTabbedPane object from a different Class? Reflection? I am at a lost
> to resolve with out a redesign.

Can't you keep a reference to the tabbedPane somewhere that your code can get
at.  Then you just do:

myTabbedPane.setComponentAt( index, newComponent);

Signature

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

IchBin - 23 Feb 2005 03:54 GMT
>>I guess my question is:
>>
[quoted text clipped - 6 lines]
>
> myTabbedPane.setComponentAt( index, newComponent);

Bill...

Thank you so much! This does work.

I thought I tried this before. Apparently I did not have the correct
object reference. It does replace the component but I had it inside a
JScrollPane. After issuing the setComponentAt() it replaces the
JScrollPane(target_panel) with the new target_panel.

I am way a head of where I have been, with your help. To replace the
JScrollPane(target_panel), not just the panel I tried:

JScrollPane dummyJScrollPane = new JScrollPane(dummypanel_B);
SelectedtabbedPane.setComponentAt( 3,  dummyJScrollPane);

Works like a charm....

Signature

Thanks again Bill...
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.