这样的话,setVisible(false)和dispose();这两个方法没有什么区别? JDK1.5这样说: dispose public void dispose() Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be ed as undisplayable. The Window and its subcomponents can be made displayable again by rebuilding the native resources with a subsequent call to pack or show. The states of the recreated Window and its subcomponents will be identical to the states of these objects at the point where the Window was disposed (not accounting for additional modifications between those actions). setVisible public void setVisible(boolean b) Shows or hides this component depending on the value of parameter b.
也可以写成setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
应该是setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE)
dipose();不要把这句话加进去setDefaultCloseOperation(3);就不会关掉了!
------------------------------------------------------------------PC火烈鸟
http://blog.csdn.net/pcfirebird/
JDK1.5这样说:
dispose
public void dispose()
Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be ed as undisplayable.
The Window and its subcomponents can be made displayable again by rebuilding the native resources with a subsequent call to pack or show. The states of the recreated Window and its subcomponents will be identical to the states of these objects at the point where the Window was disposed (not accounting for additional modifications between those actions). setVisible
public void setVisible(boolean b)
Shows or hides this component depending on the value of parameter b.
void setvisible(boolean b)根据b的取值来决定显示还是隐藏