🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #12881

Re: Panel refresh problem

#12881
From: Hugh Bonfield
Date: Thu, 29 Oct 1998 00:00
48 lines
2433 bytes
I'm just a raw beginner, but this tip might be helpful: if you want to put some
widgets on a panel, then later a different set of widgets, and swap between the
two then what works well for me is CardLayout - this is like a tab panel without
the tabs.

Hugh

Michael Deck wrote:

> I'm not a JBuilder user but a Swing user who was searching for answers
> to this same question when I saw yours. I tried the things you tried and
> all failed. Then I saw ... the isValidateRoot() method. If you create a
> subclass myPanel of JPanel and then override isValidateRoot() in it to
> return true, adding new components and then calling revalidate() will
> cause the behavior you want. Otherwise it looks like revalidate() will
> only work inside a JScrollPane.
>
> I'm not saying this is sane or reasonable behavior, just the way it
> appears to work.
>
> -Mike
>
> Frode Oldervoll wrote:
> >
> > I have a JPanel (a)  that contains different other JPanels (b), one at a
> > time, and I change the conent of panel a dynamically according to menu
> > selections. My problem is that when I change the panels b the panel a won't
> > redraw itself. I have tried various combinations of invalidate, validate,
> > revalidate, etc., as in the code included below:
> >
> >     a.removeAll();
> >     b.setVisible(true);
> >     a.add(b, "Center");
> >     b.validate();
> >     a.invalidate();
> >     a.validate();
> >     a.revalidate();
> >
> > With all these validate-methods, the panel a still don't redraw itself with
> > the correct content b. It works the first time I select a panel, but later I
> > don't work.
> >
> > What is the correct way to solve such a problem?
> >
> > By the way, I use JDK 1.1.7 and Swing 1.0.3, but the problem is the same
> > with JDK 1.1.6_Borland and Swing 1.0.1.
> >
> > -Frode
Technical Details
Message-ID: <3638A9F0.DD2A6E20@csi.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6v24o7$3kh7@forums.borland.com> <3624DDC2.B3CA4F4E@cleansoft.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,d70978371e769ca6
X-Google-Attributes: gid111d45,public
From: Hugh Bonfield <HughBonfield@csi.com>
Subject: Re: Panel refresh problem
Date: 1998/10/29
Message-ID: <3638A9F0.DD2A6E20@csi.com>
X-Deja-AN: 406355645
Content-Transfer-Encoding: 7bit
References: <6v24o7$3kh7@forums.borland.com> <3624DDC2.B3CA4F4E@cleansoft.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing