`

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{

		@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();
			}
		}
	}

	

}
  • 大小: 31.5 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics