问题 1:
% java -jar TASTS-MacOS-X64.jar
***WARNING: Display must be created on main thread due to Cocoa restrictions.
Exception in thread "main" org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4533)
at org.eclipse.swt.SWT.error(SWT.java:4448)
at org.eclipse.swt.SWT.error(SWT.java:4419)
at org.eclipse.swt.widgets.Display.error(Display.java:1089)
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:840)
at org.eclipse.swt.widgets.Display.create(Display.java:823)
at org.eclipse.swt.graphics.Device.<init>(Device.java:129)
at org.eclipse.swt.widgets.Display.<init>(Display.java:722)
at org.eclipse.swt.widgets.Display.<init>(Display.java:713)
at org.eclipse.swt.widgets.Display.getDefault(Display.java:1419)
at MainForm.main(MainForm.java:10)
解决方法:
java -XstartOnFirstThread
问题 2:
java -XstartOnFirstThread -jar TASTS-MacOS-X64.jar
Unable to create basic Accelerated OpenGL renderer.
Unable to create basic Accelerated OpenGL renderer.
Core Image is now using the software OpenGL renderer. This will be slow.
不知道是否相关...但是我只是删除了一些窗口事件绑定(beforeunload
,quit
),现在不再看到此问题。(至少现在)。不确定如何将两者链接起来,但以防万一!
解决方法:
(Deploying SWT Applications on Mac OS X)
https://www.eclipse.org/swt/macosx/
https://stackoverflow.com/questions/22926289/using-swt-under-osx
https://eclipsesource.com/blogs/2012/07/19/configuring-the-os-x-application-menu-for-swt-apps/
https://mchr3k.github.io/swtjar/osxapp.html
https://stackoverflow.com/questions/19803332/menu-doesnt-show-up-with-swt-on-mac-os-x
REF
http://www.cocoachina.com/articles/446513
在Run Configurations -> Arguments -> VM arguments设置中加入:-XstartOnFirstThread