Java how to get JFrames to start as a maximized window

I want to know how to make java JFrame as open as possible. I do not want it to be full-screen (without a window). I just want it to start as a regular program such as a web browser.

I already know about using:

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

To get the screen size, but when you apply this dimension to a JFrame, you can still drag it, even if it occupies almost the entire screen. You can click the maxim button to stop it, but I would prefer the window to start as much as possible.

Also, I'm afraid for effects that maximize the window on the contents of the window.

How should I do it?

+5
source share
1 answer

Use java.awt.Frame.setExtendedState():

public static void main(String[] args)  {

    JFrame frame = new JFrame();
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.setVisible(true);
}
+8

All Articles