1. 程式人生 > >swt為關閉視窗新增確認事件

swt為關閉視窗新增確認事件

shell.addShellListener(new ShellAdapter() {
            public void shellClosed(ShellEvent e) {
                MessageBox messagebox = new MessageBox(shell, SWT.ICON_QUESTION
                        | SWT.YES | SWT.NO);
                messagebox.setText("messageBox範例");
                messagebox.setMessage
("您確定要退出嗎?") ;
                int message = messagebox.open();
                e.doit = message == SWT.YES;
            }