問題 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 -jar TASTS-MacOS-X64.jar
問題 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://blog.csdn.net/javaee_gao/article/details/102833350
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
https://blog.csdn.net/u011686226/article/details/83143173
http://www.cocoachina.com/articles/446513
https://blog.csdn.net/u011686226/article/details/83143173
在Run Configurations -> Arguments -> VM arguments設置中加入:-XstartOnFirstThread