如何用Java编程全屏模式?

时间:2020-03-06 14:46:47  来源:igfitidea点击:

我希望我的应用程序具有全屏模式。最简单的方法是什么?我需要为此使用第三方库吗?还是JDK中已经提供了某些东西?

解决方案

尝试使用全屏独占模式API。它是在JDK 1.4版中引入的。一些功能包括:

Full-Screen Exclusive Mode - allows you to suspend the windowing system so that drawing can be done directly to the screen.
  Display Mode - composed of the size (width and height of the monitor, in pixels), bit depth (number of bits per pixel), and refresh rate (how frequently the monitor updates itself).
  Passive vs. Active Rendering - painting while on the main event loop using the paint method is passive, whereas rendering in your own thread is active.
  Double Buffering and Page Flipping - Smoother drawing means better perceived performance and a much better user experience.
  BufferStrategy and BufferCapabilities - classes that allow you to draw to surfaces and components without having to know the number of buffers used or the technique used to display them, and help you determine the capabilities of your graphics device.

链接的教程中有几个全屏独占模式示例。

在具有游戏的全屏OpenGL用户界面时,我已使用JOGL进行了此操作。这很容易。我相信该功能也是在版本5中也添加到Java中的,但是很久以前,我已经忘记了如何做到这一点(编辑:有关如何操作,请参见上面的答案)。

这实际上取决于我们用来显示界面的内容,即AWT / Spring或者OpenGL等。

Java具有全屏独占模式API,请参见Sun的本教程。

JFramesetUndecorated(true)方法