Menu problem with launchd Java program
Menu problem with launchd Java program
- Subject: Menu problem with launchd Java program
- From: Patrick Malka <email@hidden>
- Date: Tue, 12 Jan 2010 16:27:49 -0500
Hell, sorry for cross posting, but my problem is not confined to one group so I figured I would try to get the best of both worlds.
I have a Java application that is launched by Launch Services using a Launch Agent plist, with the following "ProgramArguments":
0 "java"
1 "-Xdock:icon=..."
2 "-jar"
3 "path\to\myJar.jar"
The application loads fine as specified, which is for every user, it is a user client my company developed.
The application has a menu that is created during startup. The basic startup is as follows:
private static class MacOSXApplicationAdapter extends Application {
MacOSXApplicationAdapter() {
addApplicationListener(new MacOSXMenuHandler());
addPreferencesMenuItem();
setEnabledPreferencesMenu(true);
}
}
applicationAdapter = new MacOSXApplicationAdapter();
menuBar = new JMenuBar();
...add menu items to menuBar...
invisibleRootFrame = new JFrame();
invisibleRootFrame.setUndecorated(true);
invisibleRootFrame.setVisible(true);
invisibleRootFrame.setJMenuBar(menuBar);
This too works fine during normal operation. The menu appears and works, and the MacOSXApplicationAdapter handles the about, preferences and quit correctly.
The problem comes up during a very obscure scenario.
After a log in, various processes start up and will show their menu during startup, until another process does the same till everything has started up and the last process to modify the menu bar is left showing. When this happens to our app, and it is shown in the menu bar after everything has started, the menu is unstable.
If I immediately click on the menu bar, it works fine, but if i instead close an open Finder window without changing the application displayed in the menu bar, a subsequent attempt to use the menu fails. The menu is locked until some other process is selected and has its menu shown in the system menu bar. I can reproduce this 100% of the time. I can open several Finder windows before logging out so that they are reopened during log in without any action on my part. My only action after a log in is to close an open Finder window and then click the system menu bar, which is now locked. If I click the menu bar without closing the Finder window first, the menu works fine. Note that this is true for the whole menu bar, not just my application's menus. The Apple icon is affected too! Clicking on anything results in no action once it has 'locked up'.
Also, this is true no matter how log I wait, I thought it was a race between starting up applications, but I can wait 60 seconds after a log in before performing either of the 2 choices above and the result is the same in both cases as when I had not waited.
It is quite annoying to have to click on something and then click back to restore the system menu bar, has anyone seen anything like this before?
I wonder if it is because I am running a Java application with Launch Services and using the Mac look and feel, something about the combo is not entirely supported, but I cannot find anything specifically about Java programs run with Launch Services. I can find plenty of stuff on either of those two, but not a lot on the combination. I suspect that this might be a bug, but it is hard to verify because when I remove extraneous code from my application, it changes the timing and the Finder is now the last application to start loading and so the Finder menu shows and there are no problems.
Any help is appreciated.
Thanks.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden