Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / April 2004

Tip: Looking for answers? Try searching our database.

Enabling/Disabling menuitems in a JMenu

Thread view: 
Abs - 28 Apr 2004 23:12 GMT
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 ?

thanks in advance

--
abs
xarax - 28 Apr 2004 23:38 GMT
> Hi,
>
[quoted text clipped - 6 lines]
> 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.
Abs - 29 Apr 2004 20:58 GMT
>>Hi,
>>
[quoted text clipped - 18 lines]
> methods listening for property changes (like enablement)
> for the Action items.

I'm not sure I've really understood you. I know the basics behind
Actions. What I'm trying to do in my app, a sound file player, is to
enable the "play file" menuitem AFTER the user has successfully opened a
sound file, not when he clicks the "open file" menuitem. The problem I
have is that I don't know how to reach that menuitem without having a
direct or global pointer to it in my app. That's why I thought in firing
some kind of event that this menuitem would be listening to.

Can you help me, please?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.