JFrame Maximize window

Nope picture Nope · Jan 26, 2009 · Viewed 99.2k times · Source

I'm putting together a quick and dirty animation using swing. I would like the window to be maximized. How can I do that?

Answer

kgiannakakis picture kgiannakakis · Jan 26, 2009

Provided that you are extending JFrame:

public void run() {
    MyFrame myFrame = new MyFrame();
    myFrame.setVisible(true);
    myFrame.setExtendedState(myFrame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
}