Changing swing components

Discussion in 'Java' started by moulio, May 18, 2005.

  1. moulio

    moulio Guest

    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
     
    moulio, May 18, 2005
    #1
    1. Advertising

  2. moulio

    BartCr Guest

    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
     
    BartCr, May 18, 2005
    #2
    1. Advertising

  3. moulio

    moulio Guest

    That worked great. Thanks!!!!!!

    -Thomas
     
    moulio, May 18, 2005
    #3
  4. "BartCr" <> wrote in message
    news:...
    > 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().
     
    Larry Barowski, May 18, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian Marko
    Replies:
    2
    Views:
    3,905
    Tim Tyler
    Jan 6, 2004
  2. Mickey Segal
    Replies:
    0
    Views:
    891
    Mickey Segal
    Feb 2, 2004
  3. Javaman1003

    Which swing components to use?

    Javaman1003, Feb 12, 2004, in forum: Java
    Replies:
    2
    Views:
    400
  4. T E Schmitz
    Replies:
    3
    Views:
    419
  5. mkrause
    Replies:
    0
    Views:
    674
    mkrause
    May 6, 2005
Loading...

Share This Page