If you want to open the JFrame maximized by default in swing you can use JFrame. setExtendedState()
, illusrated below:
public class MyFrame extends JFrame{
public MyFrame() {
// Other codes
// Set the JFrame to maximize by default on opening
setExtendedState(JFrame.MAXIMIZED_BOTH);
// Rest of the program
}
}
Also remember that you should not have JFrame.pack()
or JFrame.setMaximimumSize()
or JFrame.setSize()
in the same menthod (here constructor).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…