Article View: borland.public.jbuilder.java.swing
Article #12979Re: Panel refresh problem
From: Michael Deck
Date: Wed, 14 Oct 1998 00:00
Date: Wed, 14 Oct 1998 00:00
39 lines
2056 bytes
2056 bytes
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:
<3624DDC2.B3CA4F4E@cleansoft.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<6v24o7$3kh7@forums.borland.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: Michael Deck <deckm@cleansoft.com> Subject: Re: Panel refresh problem Date: 1998/10/14 Message-ID: <3624DDC2.B3CA4F4E@cleansoft.com> X-Deja-AN: 401045304 Content-Transfer-Encoding: 7bit References: <6v24o7$3kh7@forums.borland.com> Content-Type: text/plain; charset=us-ascii Organization: Cleanroom Software Engineering, Inc. Mime-Version: 1.0 Reply-To: deckm@cleansoft.com Newsgroups: borland.public.jbuilder.java.swing