Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Application menu not updating properly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Application menu not updating properly



Like most UI libraries, Swing is not thread safe. All updates to any state of a UI component needs to happen on the EDT (Event Dispatch Thread).

but, it's simple enough to do that.

Runnable menustateUpdater = new Runnable(){

	public void run()
	{
		if (shouldEnable) {
           	 menuItem1.setEnabled(true);
        	}
	{
};

SwingUtilities.invokeLater(menustateUpdater);

I typed this in Mail so there could be a typo/bug but this is the main idea of what you need to do.

Rob

On Mar 27, 2009, at 8:07 AM, Patrick Malka wrote:

I have a Mac OS X Java application that uses the system bar menu.

Everything works great but occasionally the menu is not updated properly after a setEnabled(true) call to some of the menu items.

The application updates the menu depending on its state.

        invisibleRootFrame = new JFrame();
        menuBar = new JMenuBar();
        ...
        invisibleRootFrame.setJMenuBar(menuBar);
        ...
        if (shouldEnable) {
            menuItem1.setEnabled(true);
        }

But after trying to enable the item, it is not always enabled. This is a simplification of what our code actually does, obviously, but the flow is the same. The menu is updated in a separate thread, could that have something to do with it? Only that thread updates the menu, so racing is not an issue, but could it be because it is not done on the main thread?

I have been unable to find any information on this and was wondering if others had seen this and if it was already a known issue.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Application menu not updating properly (From: Patrick Malka <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.