as stated by beyond_xiruo, place the "setVisible(true)" in the end.setVisible(true) will call the function of paint. As you place it in the beginning, the uncompleted window will be painted.The window will only be completely correctly painted once your operation invokes the method of repaint() after the first paint() operation. Here, it's the resizing action.
this.validate();
this.repaint();
改成JFrame好了
setVisible(true);
放到最后