JFrame最大化窗口

问题描述:

我正在使用swing来整理快速而肮脏的动画。我希望窗口最大化。我怎么能这样做?

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

如果您要扩展JFrame:

Provided that you are extending JFrame:

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