
_START_ARTICLE_
SWT
_START_SECTION_
编程
_START_PARAGRAPH_
下列为基本使用SWT的Hello World程式。显示出一个视窗(Shell)及一个标签。_NEWLINE_import org.eclipse.swt.*;import org.eclipse.swt.widgets.*;public class HelloWorld _NEWLINE_{_NEWLINE_   public static void main (String[] args) _NEWLINE_  {_NEWLINE_      Display display = new Display();_NEWLINE_      Shell shell = new Shell(display);_NEWLINE_      Label label = new Label(shell, SWT.NONE);_NEWLINE_      label.setText("Hello World");_NEWLINE_      label.pack();_NEWLINE_      shell.pack();_NEWLINE_      shell.open();_NEWLINE_      while (!shell.isDisposed()) _NEWLINE_      {_NEWLINE_         if (!display.readAndDispatch()) display.sleep();_NEWLINE_      }_NEWLINE_      display.dispose();_NEWLINE_   }}