javaswingmaximize-window

JFrame Maximize window


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


Solution

  • Provided that you are extending JFrame:

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