Open JFrame in maximized Java

2

I'm having a problem, I'm creating a JFrame and I want it to open maximized. I'm using the following code:

frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.setLocationRelativeTo(null);

The size of the JFrame is maximized, but the button for me to maximize is still available, so if I click it, it increases the screen a little bit more.

I want to open it actually maximized, with the restore available size button. Does anyone know what's wrong with the code? Or how? Thank you.

    
asked by anonymous 01.05.2016 / 17:11

1 answer

1

Use as follows:

frame.setVisible(true);
frame.setLocationRelativeTo(null);
frame.setExtendedState(Frame.MAXIMIZED_BOTH);

Maximized state should come after placement so that size does not change.

    
31.10.2016 / 19:39