Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Changing swing components

Reply
Thread Tools

Changing swing components

 
 
moulio
Guest
Posts: n/a
 
      05-18-2005
Hi, I have a swing gui that contains graphs, which are just modified
JPanels. I want to switch one of the graphs while the program is
running. I have tried to just switch the reference of the old graph to
the one, but this has no effect.

I have also tried removing the old graph and then adding the new one to
the container. This works a slightly better: the old graph disappears,
but the new one won't appear until the window is resized.
I'm not very familiar with swing, so any help would be great. Thanks!!!

-Thomas

 
Reply With Quote
 
 
 
 
BartCr
Guest
Posts: n/a
 
      05-18-2005
After switching the panels you'll have to make sure the container is
revalidated.
Invalidate the parent container and then call validate on it. Or if you
want to make sure the layout is updated immediately, call doLayout() on
the parent container.

Bart

 
Reply With Quote
 
 
 
 
moulio
Guest
Posts: n/a
 
      05-18-2005
That worked great. Thanks!!!!!!

-Thomas

 
Reply With Quote
 
Larry Barowski
Guest
Posts: n/a
 
      05-18-2005

"BartCr" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> After switching the panels you'll have to make sure the container is
> revalidated.
> Invalidate the parent container and then call validate on it.


Since this is a JComponent, you can just call revalidate().



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Swing Model Classes Updating Swing Components on a Thread Other Than AWT mkrause Java 0 05-06-2005 04:32 PM
SWING components adjustment in different resolutions - Should show scrollbars less than 800X600 and expand components over this resolution Bluetears76 Java 1 07-01-2004 09:01 PM
Which swing components to use? Javaman1003 Java 2 02-12-2004 02:01 PM
Can Choice components respond to keyboard input like HTML Choice components? Mickey Segal Java 0 02-02-2004 10:59 PM
Import swing-components in J2ME-Applications Christian Marko Java 2 01-06-2004 05:40 PM



Advertisments