Re: Replacing Components in a JPanel

From: Hal Vaughan (hal_at_thresholddigital.com)
Date: 10/16/03

  • Next message: cv: "Re: Urgent: MultiPartRequest does work with Internet!"
    Date: Thu, 16 Oct 2003 04:16:30 GMT
    
    

    Stella wrote:

    > You can try "invalidate()" on the container. Adding of a component doesn't
    > always trigger the layout manager to relayout the container and by
    > invalidating the container the layout manager will be triggered to do
    > relayout. The first time the layout manager will be triggered by the
    > show().
    > Stellah

    Tried it. I have no idea why, but it didn't work. Someone below suggested
    using a CardLayout (new to me -- which isn't a surprise).

    Thanks for the idea. I didn't know about invalidate() and will definately
    keep it in mind for similar situations in the future.

    Hal

    >
    > "Hal Vaughan" <hal@thresholddigital.com> schreef in bericht
    > news:NQhjb.787330$uu5.137635@sccrnsc04...
    >> I have a JPanel in a window and I am putting different components in it
    >> as
    >> the user goes through a setup wizard. In theory, I have an array of
    >> components (other JPanels), and I want to step through them, displaying
    >> panel_0, then panel_1....
    >>
    >> I have no problem removing panel_0 from the JPanel parent (I've even done
    > a
    >> repaint() right after removing to be sure of this), but no matter what I
    >> do, I can't seem to do an "add(panel_1)" to the sampe panel. It's the
    > same
    >> method I'm using to add the first panel, before I show() the window, but
    >> once I remove a component and try to add another in its place, I get a
    >> blank.
    >>
    >> Is there a reason I can't add components? Is it because the window is
    >> visible? What do I need to do?
    >>
    >> Thanks!
    >>
    >> Hal


  • Next message: cv: "Re: Urgent: MultiPartRequest does work with Internet!"

    Relevant Pages

    • Re: Replacing Components in a JPanel
      ... You can try "invalidate" on the container. ... always trigger the layout manager to relayout the container and by ... invalidating the container the layout manager will be triggered to do ...
      (comp.lang.java)
    • Re: AWT/Swing layout behavior?
      ... I have some sample code that I _expected_ would take the two components added to the frame and always make them the same size, ... What happens instead is that when one of the two components is a Panel or JPanel (and possibly other container types...those are the two I tested), if that component contains another component, it takes up more than half of the frame. ... In that case, the size difference is proportionally larger as well, resulting in effective relative weights more like 3 or 4 to 1. ... With GBL if you put more into the container than will fit, the layout manager will squash some or all of the components to invisibility. ...
      (comp.lang.java.programmer)
    • Re: Removing all data out of JList
      ... the JavaDoc says "Removes all the components from this container. ... method also notifies the layout manager to remove the components from ...
      (comp.lang.java.help)
    • Re: JComboBox
      ... fact that my JPanel has a layout manager to null? ... That sort of programming is highly discouraged in Java. ... manually set the size of every component, ... makes sure the size and position of the container is suitable. ...
      (comp.lang.java.programmer)
    • bypass the container.click() ?
      ... on an object inside a container ... trigger Container.Click ... SGA - UTN - FRBA ...
      (microsoft.public.fox.programmer.exchange)