Article View: borland.public.jbuilder.java.swing
Article #10674Re: JMenuBar painting problem
From: Jim Stoll
Date: Wed, 18 Aug 1999 00:00
Date: Wed, 18 Aug 1999 00:00
61 lines
3204 bytes
3204 bytes
I hadn't tried the invalidate() followed by the repaint(), but unfortunately, that didn't solve the problem either (though it did improve it over what it was prior to the show() method approach...) If you get a few moments, try adding another button that adds a menu to the menubar and see if that works for you. When I add a menu, it doesn't show up until I click the JFrame's border. When I remove a menu, I end up w/ a 'hole' in the menubar where the removed item was. The general scheme that I have is as follows: MDIFrame extends JFrame MDIDesktopPane extends JDesktopPane MDIDesktopManager extends DefaultDesktopManager MDISheet extends JInternalFrame MDIDesktopPane is added to MDIFrame's ContentPane. MDIDesktopManager is set as MDIDesktopPane's DesktopManager and calls MDISheet.setupMenu() whenever a sheet is activated and calls MDISheet.cleanupMenu() whenever a sheet is deactivated or closed. I add/remove menu stuff to/from the frame's JMenuBar in the sheet's setup/cleanup methods (sheets are subclassed from MDISheet...). Seemingly endless combinations of paint, repaint, update, validate, invalidate, show and quite imaginative combinations of four-letter verbal commands have failed to cause menu stuff added/removed in setup/cleanup to show up w/o needing to click around in the menubar or resize the frame. The one exception to this is calling MDIFrame.show(), which kinda sucks... :-) I appreciate the help!! Jim "Paul Furbacher [TeamB]" wrote: > Jim Stoll wrote: > > > I've tried both invalidate() and revalidate() on the menu bar, content pane, > > root pane and the JFrame itself, but all with no discernable effect. [...] > > I did to test whether invalidate() works to overcome what > appear to be your problem. It does work in conjunction > with repaint(...), but maybe I wasn't doing exactly what > you have been trying to do. > > I put a JMenuBar with File, Edit and Help menus in it into a JFrame. > In the File menu, I added an Open and a Close menu item. > > I dropped a button on the frame and in its actionPerformed > handler, I wrote: > > menuBar.remove(editMenu); > fileMenu.remove(openMenuItem); > menuBar.invalidate(); > menuBar.repaint(100); > > That worked: the Edit menu disappeared and the Help menu > moved to the left. Upon popping down the File menu, only > Close appeared. > > Remove the invalidate() and it appears as if the Edit menu > were still in the menuBar component. > > Paul Furbacher (TeamB)
Technical Details
Message-ID:
<37BB1F60.6177EEA2@crtnet.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<37B9940A.BB6B5F97@crtnet.com> <37B9DE36.91FDB14D@bilbo.bio.purdue.edu> <37BAA3F7.C4E4D0B1@crtnet.com> <37BAC7E8.4213E34D@bilbo.bio.purdue.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,9687ead9ed7fb42d X-Google-Attributes: gid111d45,public From: Jim Stoll <jestoll@crtnet.com> Subject: Re: JMenuBar painting problem Date: 1999/08/18 Message-ID: <37BB1F60.6177EEA2@crtnet.com> X-Deja-AN: 514366901 Content-Transfer-Encoding: 7bit References: <37B9940A.BB6B5F97@crtnet.com> <37B9DE36.91FDB14D@bilbo.bio.purdue.edu> <37BAA3F7.C4E4D0B1@crtnet.com> <37BAC7E8.4213E34D@bilbo.bio.purdue.edu> 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