親フォルダ
01.import org.eclipse.jface.window.ApplicationWindow;
02.import org.eclipse.swt.SWT;
03.import org.eclipse.swt.events.SelectionAdapter;
04.import org.eclipse.swt.events.SelectionEvent;
05.import org.eclipse.swt.graphics.Point;
06.import org.eclipse.swt.widgets.Button;
07.import org.eclipse.swt.widgets.Composite;
08.import org.eclipse.swt.widgets.Control;
09.import org.eclipse.swt.widgets.Display;
10.import org.eclipse.swt.widgets.MessageBox;
11.import org.eclipse.swt.widgets.Shell;
12. 
13.public class Main extends ApplicationWindow {
14. 
15.    public Main() {
16.        super(null);
17.        createActions();
18.        addToolBar(SWT.FLAT | SWT.WRAP);
19.        addMenuBar();
20.        addStatusLine();
21.    }
22. 
23.    @Override
24.    protected Control createContents(Composite parent) {
25.        Composite container = new Composite(parent, SWT.NONE);
26.         
27.        Button button = new Button(container, SWT.NONE);
28.        button.addSelectionListener(new SelectionAdapter() {
29.            @Override
30.            public void widgetSelected(SelectionEvent e) {
31.                 
32.                System.out.println("クリックされました");
33.                 
34.                Shell shell = Main.this.getShell();
35.                 
36.                MessageBox messageBox = new MessageBox( shell, SWT.YES | SWT.NO );
37.                messageBox.setMessage("YESかNOを選択してください");
38.                messageBox.setText("メッセージ");
39.                int result = messageBox.open();
40. 
41.                if( result == SWT.YES ) {
42.                    System.out.println("YESがクリックされました");
43.                }
44.                if( result == SWT.NO ) {
45.                    System.out.println("NOがクリックされました");
46.                }
47.                 
48.            }
49.        });
50.        button.setBounds(55, 35, 75, 25);
51.        button.setText("実行");
52. 
53.        return container;
54.    }
55. 
56.    private void createActions() {
57.        // Create the actions
58.    }
59. 
60. 
61.    public static void main(String args[]) {
62.        try {
63.            Main window = new Main();
64.            window.setBlockOnOpen(true);
65.            window.open();
66.            Display.getCurrent().dispose();
67.        } catch (Exception e) {
68.            e.printStackTrace();
69.        }
70.    }
71. 
72.    @Override
73.    protected void configureShell(Shell newShell) {
74.        super.configureShell(newShell);
75.        newShell.setText("New Application");
76.    }
77. 
78.    @Override
79.    protected Point getInitialSize() {
80.        return new Point(450, 300);
81.    }
82.}