fack()是Window类的方法:
Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.  If the window and/or its owner are not yet displayable, both are made displayable before calculating the preferred size.  The Window will be validated after the preferredSize is calculated.validate()是Component、Container类的方法:
The validate method is used to cause a container to lay out its subcomponents again. It should be invoked when this container's subcomponents are modified (added to or removed from the container, or layout-related information
changed) after the container has been displayed.

解决方案 »

  1.   

    validate是使容器重新排列它上面的組件﹐它應在容器的組件發生更改(組件從容器中新增﹐刪除或layout發生更改時)時調用。
    pack()方法是根據它所容納的組件計算它的最合適的大小﹐然後變到這個大小。它的作用是根據容器上的組件的最佳大小將容器調整到可能的最小.
    寫的很拗口﹐不過你試一下就知道了
      

  2.   

    enableEvents(AWTEvent.WINDOW_EVENT_MASK);再问一句,这是什么意思?
      

  3.   

    充许窗口事件处理,如窗口打开、关闭等。如果你disableEvents(AWTEvent.WINDOW_EVENT_MASK);那么,窗口将对关闭事件等不响应。你可以试一下,默认是enable的