SWT(一)一个最简单的SWT程序示例


public class Test{

 private Shell sShell = null; 

 
 /**
  * This method initializes sShell
  */
 private void createSShell() {
 
  sShell = new Shell();
  sShell.setLayout(gridLayout7);
  sShell.setSize(new Point(276, 195));
  sShell.setText("Shell");
  sShell.setLayout(gridLayout);
  sShell.setSize(new Point(341, 205));

  Label cLabel = new Label(sShell, SWT.NONE);
  cLabel.setText("Test a label");
 }
 
 public void Run()
 {
       try {
            createSShell();
        
            Display display = this.sShell.getDisplay();
            this.sShell.open();
            while (!this.sShell.isDisposed()) {             
                if (!display.readAndDispatch())
                    display.sleep();
            }
           
            sShell.dispose();
            display.dispose();
        } catch (Exception e) {
            e.printStackTrace();
        }
 }
 
 public static void main(String args[]) {
  new Test().Run();
    }

}

原文地址:https://www.cnblogs.com/huqingyu/p/580070.html