I'm working on application and I'm making the GUI with Swing. I would like my application to be fullscreen. I can easily set the size of the window however I have not been able to make the application truly fullscreen (IE With the apple menu bar and dock hidden). All the answers I have found online don't seem to work for me. I'm new to Java so any help is appreciated.
frame = new JFrame("Test");
frame.setTitle("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel emptyLabel = new JLabel("");
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
frame.setSize((int)dimension.getWidth(), (int)dimension.getHeight());
int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2); // X center
int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2); //Y center
frame.setLocation(x, y); //Set Frame Location
frame.setResizable(false); //Frame is not resizable
frame.setUndecorated(true); //No decoration for the frame
frame.setAlwaysOnTop(true);
frame.setVisible(true); //Make visible