这里有[size=large]详细的事件列表:[/size][url]http://blog.youkuaiyun.com/fangfang200805/article/details/4553929[/url]
[img]http://dl.iteye.com/upload/attachment/0065/8057/c2e077d2-150d-3d22-9c27-5435615cfd44.png[/img]
[img]http://dl.iteye.com/upload/attachment/0065/8057/c2e077d2-150d-3d22-9c27-5435615cfd44.png[/img]
import org.eclipse.swt.events.ShellEvent;
/**
* @author LC
*version: 2012_03_31
*/
public class TestShellEvent {
//shell事件监听器啊!
static class ShellListenerPrint implements ShellListener{
@Override
public void shellActivated(ShellEvent e) {
System.out.println("Activated:\n\t"+e);
}
@Override
public void shellClosed(ShellEvent e) {
// e.doit=false;//这样就关不了了!! doit 意思应该是 do it吧
System.out.println("Closed:\n\t"+e);
}
@Override
public void shellDeactivated(ShellEvent e) {
System.out.println("Deactivated:\n\t"+e);
}
@Override
public void shellDeiconified(ShellEvent e) {
System.out.println("Deiconified:\n\t"+e);
}
@Override
public void shellIconified(ShellEvent e) {
System.out.println("Iconified:\n\t"+e);
}
}
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell(display);
shell.setSize(280, 150);
shell.setText("测试shell相关的事件");
// shell.setMaximized(true);
shell.addShellListener(new ShellListenerPrint());//添加监听器
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}