How can I create a Java Swing application that spans the Windows title bar?

I am working on a java swing application that will be used in a psychology experiment, and the researchers asked me to make the program β€œblacked out” so that there are no external incentives for the user. They want the swing app to be truly full-screen and without any type of headers or minimize / enlarge / close buttons at the top.

The software will run on Windows XP using JavaSE 6.

How can I do this and, if necessary, provide a piece of code.

Thanks!

+5
source share
3 answers

Use fullscreen 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); } 
+11
source

Use the setUndecorated(true) property. Please note that this must 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); 
+9
source

I know this thread is outdated, but I found it while searching for how to do the same myself. I could not find the solutions I wanted to use, so I came up with this. I found that the solution below not only works, but is also much simpler than the answers above.

 JFrame frame = new JFrame(); frame.setResizable(false); frame.setUndecorated(true); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); frame.setSize(dim); frame.setVisible(true); 
0
source

Source: https://habr.com/ru/post/910811/


All Articles