I am writing a Java application designed for all platforms, but in particular I am working on the appearance and integration of OS X (I use NetBeans on my MacBook Pro). I would like to access the application menu, i.e. A bold menu named after the application. I want to register listeners for the About and Quit elements, and also show the Preferences element. I would not mind adding a few more of my own.
So how do I do this? I saw that the previous posts were related to the OSXAdapter, but the geniuses at Apple decided to remove it from their library (or rename it ambiguously), because all links were redirected to the main page, and all my searches were fruitless. I also saw the MacOSAppAdapter class, but I'm not sure how to use it. All importing and new classes and hierarchies are a little confused.
EDIT:
This is what I did to link the About, Preferences, and Quit elements:
I created a new class, MacOSXAboutHandler, which extends
com.apple.eawt.Application
Its constructor just calls
setAboutHandler(AboutHandler aH)
and I provide it with my own listener, which expands
AboutHandler
In my main class, I determine if I'm running on a Mac using
System.getProperty("os.name").contains("mac")
If true, I'm just creating a new instance of MacOSXAboutHandler. The constructor adds my handler, and whenever the application is launched (or even tested in NetBeans), clicking on the About ... element in the selected application menu executes the code that I specified in my AboutHandler.
The same is done for preference and termination, simply replacing the occurrences of "about" with the appropriate action. All of these handlers are written like any other Java listener.