Fullscreen feature for Java Apps on OSX Lion

后端 未结 6 602
你的背包
你的背包 2020-11-30 09:01

How can I (natively) implement the fullscreen feature of OSX Lion in a Java application?

The current answers given incorporate a good method for achieving a sort-of-

6条回答
  •  一生所求
    2020-11-30 09:24

    What you are trying to do can be done through the com.apple.eawt library. Additionally in order to avoid writing code through reflection if you also deploy your application on other OSes like Windows, Linux etc. you should use and distribute embeded within your application the AppleJavaExtensions.jar from Apple.

    This is the method to make a frame expandable in full screen:

    FullScreenUtilities.setWindowCanFullScreen(window,true);
    

    And this is the method to toggle full screen:

    Application.getApplication().requestToggleFullScreen(window);
    

    where the parameter window is the JFrame of your application that you are trying to make full screen capable.

    To see an example application have a look at RationalPlan Project.

提交回复
热议问题