如何创建覆盖 Windows 标题栏的 Java Swing 应用程序? [英] How can I create a Java Swing app that covers the Windows Title bar?
问题描述
我正在开发一个将用于心理学实验的 java swing 应用程序,研究人员要求我让程序黑屏",以便用户不会受到外界刺激.他们希望 Swing 应用真正全屏显示,顶部没有任何类型的标题栏或最小化/最大化/关闭按钮.
I'm working on a java swing application that will be used in a psychology experiment and the researchers have requested that I make the program "black out the screen" in order that there should be no outside stimuli for the user. They want the swing app to be truly full-screen and without any type of title bar or minimize/maximize/close buttons on the top.
该软件将在使用 JavaSE 6 的 Windows XP 环境中运行.
The software will be running in a Windows XP environment using JavaSE 6.
我该怎么做,如果适用,请提供代码片段.
How can I do this and please provide a code snippet if applicable.
谢谢!
推荐答案
使用全屏 Java API?
Use the Full Screen Java APIs?
http://java.sun.com/docs/books/tutorial/extra/fullscreen/exclusivemode.html
http://www.artificis.hu/2006/03/16/java-awtswing-fullscreen
JFrame fr = new JFrame();
fr.setResizable(false);
if (!fr.isDisplayable()) {
// Can only do this when the frame is not visible
fr.setUndecorated(true);
}
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
try {
if (gd.isFullScreenSupported()) {
gd.setFullScreenWindow(fr);
} else {
// Can't run fullscreen, need to bodge around it (setSize to screen size, etc)
}
fr.setVisible(true);
// Your business logic here
} finally {
gd.setFullScreenWindow(null);
}
这篇关于如何创建覆盖 Windows 标题栏的 Java Swing 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!