I have done a bunch of research and I have looked through many examples but I cannot figure out why my code is not working. I am attempting to make a window full screen(no toolbars or anything, ACTUAL full screen) and have been playing around with the code: (from http://docs.oracle.com/javase/tutorial/extra/fullscreen/exclusivemode.html)
EDIT: People are not getting it. Im quite confident that this code below, does what i want it to, sets the frame full screen. Its just not working for me! Telling me to use .setExtendedState(JFrame.MAXIMIZED_BOTH) is not what im looking for.
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice dev = env.getDefaultScreenDevice();
System.out.println(dev.isFullScreenSupported());
dev.setFullScreenWindow(frame);
I dont fully understand what the code does but i know it is not making my window full screen. i have looked through other examples and this seems to be the way to do it. This is the rest of my code(so far, im just starting a new project):
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
public class Main extends JFrame {
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Main frame = new Main();
frame.setResizable(false);
frame.setUndecorated(false);
frame.setVisible(true);
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice dev = env.getDefaultScreenDevice();
//this returns true
System.out.println(dev.isFullScreenSupported());
dev.setFullScreenWindow(frame);
frame.validate();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Main() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
}
}