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.
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.
Thanks!
put("JFrame. activeTitleBackground", Color. red); for change the toolbar color in JFrame.
Swing API is a set of extensible GUI Components to ease the developer's life to create JAVA based Front End/GUI Applications. It is build on top of AWT API and acts as a replacement of AWT API, since it has almost every control corresponding to AWT controls.
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);
}
Use the setUndecorated(true)
property. Note that this has to be done before making the frame visible.
JFrame frame = new JFrame();
Toolkit tk = Toolkit.getDefaultToolkit();
frame.setBounds(new Rectangle(new Point(0, 0), tk.getScreenSize()));
frame.setUndecorated(true);
frame.setVisible(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With