Advertisement
Guest User

Untitled

a guest
May 2nd, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. package org.eclipse.swt.snippets;
  2.  
  3. import org.eclipse.swt.widgets.Display;
  4. import org.eclipse.swt.widgets.Shell;
  5. import org.eclipse.swt.widgets.Text;
  6. import org.eclipse.swt.SWT;
  7.  
  8. public class GUI {
  9.  
  10.     protected Shell shell;
  11.     private Text text;
  12.  
  13.     /**
  14.      * Launch the application.
  15.      *
  16.      * @param args
  17.      */
  18.     public GUI() {
  19.         Thread thread = new Thread(){
  20.             public void run(){
  21.         try {
  22.             open();
  23.         } catch (Exception e) {
  24.             e.printStackTrace();
  25.                 }
  26.             }
  27.         };
  28.         thread.start();
  29.     }
  30.  
  31.     /**
  32.      * Open the window.
  33.      */
  34.     public void open() {
  35.         Display display = Display.getDefault();
  36.         createContents();
  37.         shell.open();
  38.         shell.layout();
  39.         while (!shell.isDisposed()) {
  40.             if (!display.readAndDispatch()) {
  41.                 display.sleep();
  42.             }
  43.         }
  44.     }
  45.  
  46.     /**
  47.      * Create contents of the window.
  48.      */
  49.     protected void createContents() {
  50.         shell = new Shell();
  51.         shell.setSize(450, 300);
  52.         shell.setText("SWT Application");
  53.  
  54.         text = new Text(shell, SWT.BORDER);
  55.         text.setBounds(180, 122, 188, 107);
  56.  
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement