Re: Enabling/Disabling menuitems in a JMenu
From: xarax (xarax_at_email.com)
Date: 04/29/04
- Next message: Dave: "Applet problems"
- Previous message: Abs: "Enabling/Disabling menuitems in a JMenu"
- In reply to: Abs: "Enabling/Disabling menuitems in a JMenu"
- Next in thread: Abs: "Re: Enabling/Disabling menuitems in a JMenu"
- Reply: Abs: "Re: Enabling/Disabling menuitems in a JMenu"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 28 Apr 2004 22:38:32 GMT
"Abs" <abs@terra.com> wrote in message
news:c6pa7o$eeq1g$1@ID-111961.news.uni-berlin.de...
> Hi,
>
> The application I'm developing has a JMenu, like any other Swing app
> out there. The menuitems in that JMenu are enabled/disabled according
> to the state of the app. I'd like to know which is the best way to
> enable or disable the individual JMenuItems from any point in the
> app, do I have to hold a global pointer to every JMenuItem in the
> app and call setEnable() ? Or can I send a change event which
> is captured by a hypothetical enablelistener registered in
> every menu item ?
I use Action and ActionListener things. If a menu item [A]
enablement status is dependent only on another menu item [B],
then I also listen for property change events on the
Action item for [B] and set the enablement of [A].
The individual Action items for [A] and [B] have
actionPerformed(ActionEvent) methods that are
called whenever the corresponding menu item [A]
or [B] is selected. You can also have PropertyChangeListener
methods listening for property changes (like enablement)
for the Action items.
- Next message: Dave: "Applet problems"
- Previous message: Abs: "Enabling/Disabling menuitems in a JMenu"
- In reply to: Abs: "Enabling/Disabling menuitems in a JMenu"
- Next in thread: Abs: "Re: Enabling/Disabling menuitems in a JMenu"
- Reply: Abs: "Re: Enabling/Disabling menuitems in a JMenu"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]