I am using the current version of SWT to build my applications, and I want to run it under Mac OS X (Yosemite).
My problem is that I canβt fix clicks on the menu items "About the program", "Settings" and "Exit", which were automatically added to my application.
I have searched many times and found the following class that helps me a lot http://www.transparentech.com/files/CocoaUIEnhancer.java .
And my code to initialize it:
import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; public class Test { private Display display; private Shell shell; public Test(Display display) { this.display = display; initUI(); } public void open() { shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } private void initUI() { shell = new Shell(display); shell.setSize(808, 599); shell.setText("Test"); AboutHandler aboutHandler = new AboutHandler(); PreferencesHandler preferencesHandler = new PreferencesHandler(); QuitHandler quitHandler = new QuitHandler(); CocoaUIEnhancer uienhancer = new CocoaUIEnhancer("Test"); uienhancer.hookApplicationMenu(display, quitHandler, aboutHandler, preferencesHandler); } private class AboutHandler implements Listener { public void handleEvent(Event e) { } } private class PreferencesHandler implements Listener { public void handleEvent(Event e) { } } private class QuitHandler implements Listener { public void handleEvent(Event e) { } } }
I can compile it without any errors, but if I run the program, I will get the following exception:
Exception in thread "main" java.lang.NoSuchMethodError: actionProc at org.eclipse.swt.internal.Callback.bind(Native Method) at org.eclipse.swt.internal.Callback.<init>(Unknown Source) at org.eclipse.swt.internal.Callback.<init>(Unknown Source) at org.eclipse.swt.internal.Callback.<init>(Unknown Source) at CocoaUIEnhancer.initialize(CocoaUIEnhancer.java:124) at CocoaUIEnhancer.hookApplicationMenu(CocoaUIEnhancer.java:92) at Test.initUI(Test.java:50) at Test.<init>(Test.java:18)
This is probably a mistake in the native libraries, but I can't figure it out!
source share