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
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);
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);
}
I know this thread is old but I found it while searching on how to do the same thing myself. I couldn't find any solutions I wanted to use so I came up with this. I found that the below solution not only works but is also much simpler than the above answers.
JFrame frame = new JFrame();
frame.setResizable(false);
frame.setUndecorated(true);
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
frame.setSize(dim);
frame.setVisible(true);