问题
I am trying to override the about menu in a Java Application on OS X Lion or anything from Leopard & above. How do I do that? The tutorials I have read so far do not seem up-to-date, some classes are no longer in the Java Mac SDK and others' events are not fired, alas.
Thanks in advance!
回答1:
You might find the instructions on http://simplericity.com/2007/10/02/1191336060000.html interesting if you use maven as the underlying Apple instructions on http://developer.apple.com/library/mac/documentation/Java/Reference/1.5.0/appledoc/api/index.html require reflection to use reliably on non-Apple JDK's too.
"This class permits your Java application to respond Mac OX X-specific Apple events. To use this class:
Obtain an instance of Application.
Instantiate one or more objects that implement the ApplicationListener interface. (A convenience class, com.apple.eawt.ApplicationAdaptor, is provided. Create an instance of it for default handling of the events in the ApplicationListener interface).
Implement handlers for the appropriate events.
Register the ApplicationAdaptor(s) with the Application object. "
Perhaps you missed this part?
EDIT: It appears this was seriously changed in 10.6 update 3 and 10.5 update 8. Show a normal Java dialogue box inside the handler in
Application a = Application.getApplication();
a.setAboutHandler(new AboutHandler() {
public void handleAbout(AboutEvent arg0) {
// here
}
});
来源:https://stackoverflow.com/questions/6884272/java-os-x-lion-about-menu