Open Mac fullscreen out of java application

淺唱寂寞╮ 提交于 2020-01-06 11:49:09

问题


my Java application is able to use fullscreen mode with mac thanks to this code:

Class util = Class.forName("com.apple.eawt.FullScreenUtilities");
Class params[] = new Class[]{Window.class, Boolean.TYPE};
Method method = util.getMethod("setWindowCanFullScreen", params);
method.invoke(util, myJFrame, true);

But this only enables fullscreen button at the right upper corner. Is it possible to go to fullscreen mode out of the application, as example by JButton-click?

It's only relevant for Mac OS X.

Thanks!


回答1:


If you're using OS X (10.7 and higher), you can use the native fullscreen mode. Use this method to request the window go on full screen mod :

com.apple.eawt.Application.getApplication().requestToggleFullScreen(window);

Where window is your JFrame for example.

EDIT : You can also see the example given by @trashgod in his comment.

Hope this could help.



来源:https://stackoverflow.com/questions/25270465/open-mac-fullscreen-out-of-java-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!