读书人

SWT学习札记6Shell相关的事件

发布时间: 2012-08-26 16:48:06 作者: rapoo

SWT学习笔记6——Shell相关的事件
这里有详细的事件列表:http://blog.csdn.net/fangfang200805/article/details/4553929



import org.eclipse.swt.events.ShellEvent;/** * @author LC *version: 2012_03_31 */public class TestShellEvent {//shell事件监听器啊!static class ShellListenerPrint implements ShellListener{@Overridepublic void shellActivated(ShellEvent e) {System.out.println("Activated:\n\t"+e);}@Overridepublic void shellClosed(ShellEvent e) {//e.doit=false;//这样就关不了了!! doit 意思应该是 do it吧System.out.println("Closed:\n\t"+e);}@Overridepublic void shellDeactivated(ShellEvent e) {System.out.println("Deactivated:\n\t"+e);}@Overridepublic void shellDeiconified(ShellEvent e) {System.out.println("Deiconified:\n\t"+e);}@Overridepublic 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();}}}}

读书人网 >编程

热点推荐