public class MacOSXMenuAdapter
extends java.lang.Object
implements java.lang.reflect.InvocationHandler
Implementation notes: The "public" API for this stuff is actually not public at all
but part of Apples JRE release. Thus, in order to stay platform independent,
we do a lot of reflection magic here (following Apples advises). This object
serves as a java.lang.reflect.Proxy
for an
com.apple.eawt.ApplicationListener
interface that is plugged into Apples
com.apple.eawt.Application
class. Since the EAWT classes are
not directly accessible (except on Mac OS X), they are loaded using
Class.forName
. Wow, I'm not sure if MS could do worse!
Modifier and Type | Class and Description |
---|---|
static class |
MacOSXMenuAdapter.OSXCOMMAND
These enum constants represent the methods that can potentially be called
on the
ApplicationListener interface. |
Constructor and Description |
---|
MacOSXMenuAdapter()
Instantiates the
Application class and initialises this
as a Proxy for interface ApplicationListener . |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Implementation of the InvocationHandler interface.
|
void |
registerEventHandler(java.awt.event.ActionListener listener,
MacOSXMenuAdapter.OSXCOMMAND cmd)
Adds an ActionListener for the specified command.
|
public MacOSXMenuAdapter()
Application
class and initialises this
as a Proxy for interface ApplicationListener
. Wires the two together.public void registerEventHandler(java.awt.event.ActionListener listener, MacOSXMenuAdapter.OSXCOMMAND cmd)
listener
- to be executed on the indicated command.cmd
- the command to trigger the action.public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
invoke
in interface java.lang.reflect.InvocationHandler
proxy
- the proxy instance that the method was invoked on.method
- the Method instance corresponding to the interface method invoked.
This is supposed to be one of the methods of class
com.apple.eawt.ApplicationListener
args
- method arguments, i.e. an instance of
com.apple.eawt.ApplicationEvent
java.lang.Throwable