1 import org.eclipse.swt.SWT; ------------------------(1)インポート宣言 2 import org.eclipse.swt.widgets.*; 3 4 public class SampleSWT { 5 public static void main(String[] args) { 6 Display display = new Display(); ----(2)Displayオブジェクト作成 7 Shell shell = new Shell(display); ----------(3)ウィジェット作成 8 Label label = new Label (shell, SWT.BORDER); 9 label.setText("Hello World"); 10 label.pack(); 11 shell.pack(); 12 shell.open(); 13 14 while (!shell.isDisposed()) { -------------(4)メッセージループ 15 if (!display.readAndDispatch()) 16 display.sleep(); 17 } 18 display.dispose(); ----------------------------(5)リソース破棄 19 } 20 }