当一个控件被dispose后(即widget.isDispose返回为true时),调用该控件的任何方法,都将报异常:
org.eclipse.swt.SWTException: Widget is disposed
当然,在内存中,控件对应的对象仍然是存在的,并且只要它被引用,垃圾回收器就不会去回收它。
文档说明:
* Returns true if the widget has been disposed,
* and false otherwise.
* This method gets the dispose state for the widget.
* When a widget has been disposed, it is an error to
* invoke any other method using the widget.
本文探讨了SWT框架中控件的处置机制。当控件被处置后,调用其任何方法都会引发异常。文章解释了如何检查控件是否已被处置,并指出尽管控件已不可用,但其对象仍存在于内存中,直至被垃圾回收。
1万+

被折叠的 条评论
为什么被折叠?



