#how do i fullscreen my jframe?
1 messages · Page 1 of 1 (latest)
<@&987246487241105418> please have a look, thanks.
these are the classes where i create and use jframe/jpanel
I uploaded your attachments as Gist. This makes them more accessible, for example to mobile users.
Try to remove the window.pack();
didnt work and i got this error: ```Exception in thread "main" java.awt.IllegalComponentStateException: The frame is displayable.
at java.desktop/java.awt.Frame.setUndecorated(Frame.java:931)
at MyGame/main.Main.main(Main.java:30)
Detected code, here are some useful tools:
[WARNING] The code couldn't end properly...
Problematic source code:
Exception in thread "main" java.awt.IllegalComponentStateException: The frame is displayable.
at java.desktop/java.awt.Frame.setUndecorated(Frame.java:931)
at MyGame/main.Main.main(Main.java:30)```
Cause:
The code doesn't compile:
';' expected
## System out
[Nothing]
didnt work sadly
And call window.setVisible(true); just when you wanna show the Frame not right after the new JFrame()
I've just test it
oh now it works tyssm
import javax.swing.*;
public class TestSwing {
public static void main(String... args) {
JFrame window = new JFrame();
//window.setVisible(true); // <-------- Don't set it here!
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setResizable(false);
window.setTitle("2D Adventure");
//Just for test!
JButton button = new JButton("Test");
window.add(button);
window.setExtendedState(window.MAXIMIZED_BOTH);
//window.pack(); // <-------- Don't use pack!
window.setLocationRelativeTo(null);
window.setVisible(true);
}
}
Detected code, here are some useful tools:
System out
[Nothing]