1

I have been using this code to manually set the screen to my monitors pixel dimensions:

public static void main(String[] args) {
        Game game = new Game("ColoursAndShapes", 1920, 970);
        game.start();
}

I would like to find a way to set the JFrame to fullscreen on any monitor, but considering my "Game" Class contains other methods and variables, I can't remove it from this launcher code.

GoldNugget8
  • 129
  • 1
  • 4

1 Answers1

2
JFrame JFrame = new JFrame();
frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setUndecorated(true); 
frame.setVisible(true);
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Rahul Gupta
  • 504
  • 4
  • 17
  • 1
    While this code snippet may solve the question, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, this reduces the readability of both the code and the explanations! – rene Aug 16 '17 at 21:02