Example usage for org.eclipse.swt.widgets Display Display

List of usage examples for org.eclipse.swt.widgets Display Display

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Display Display.

Prototype

public Display() 

Source Link

Document

Constructs a new instance of this class.

Usage

From source file:PlainLabelExample.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell();
    shell.setLayout(new GridLayout(1, false));

    // Create a label
    new Label(shell, SWT.NONE).setText("This is a plain label.");

    shell.open();/*from  w w  w  . ja va 2s.co m*/
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:FillLayoutVERTICAL.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout(SWT.VERTICAL));
    new Button(shell, SWT.PUSH).setText("one");
    new Button(shell, SWT.PUSH).setText("two");
    new Button(shell, SWT.PUSH).setText("three");
    shell.open();//from   w  w  w .  j av  a 2 s  .  c o  m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:FillLayoutHorizontal.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout(SWT.HORIZONTAL));
    new Button(shell, SWT.PUSH).setText("one");
    new Button(shell, SWT.PUSH).setText("two");
    new Button(shell, SWT.PUSH).setText("three");
    shell.open();/*from w  w w  .  ja v a2  s.  c o m*/
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:TextTextSelection.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    final Text t = new Text(shell, SWT.BORDER | SWT.MULTI);
    t.setText("here is some text to be selected");

    t.selectAll();/*from w  ww. j  a va2 s.c  o  m*/

    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:SeparatorLabelExample.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell();
    shell.setLayout(new GridLayout(1, false));

    // Create a vertical separator
    new Label(shell, SWT.SEPARATOR);

    shell.open();//  w  ww.  j  a v  a 2 s .  co  m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:CursorSetControl.java

public static void main(String[] args) {
    Display display = new Display();

    Cursor cursor = new Cursor(display, SWT.CURSOR_HAND);

    Shell shell = new Shell(display);
    shell.open();//from   w  w w  . j  a v  a2  s. co m
    final Button b = new Button(shell, 0);
    b.setBounds(10, 10, 200, 200);
    b.setCursor(cursor);

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    cursor.dispose();
    display.dispose();
}

From source file:ToolItemToolTip.java

public static void main(String[] args) {

    Display display = new Display();
    Shell shell = new Shell(display);

    ToolBar bar = new ToolBar(shell, SWT.BORDER);
    bar.setBounds(0, 20, 200, 64);//w  ww . j av a  2 s .  c  o m
    ToolItem item1 = new ToolItem(bar, 0);
    item1.setToolTipText("ToolItem \n toolTip");

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:TabItemToolTip.java

public static void main(String[] args) {

    Display display = new Display();
    Shell shell = new Shell(display);

    TabFolder folder = new TabFolder(shell, SWT.BORDER);
    folder.setSize(200, 200);//  w  w  w .j  a  va  2 s  . co m
    TabItem item0 = new TabItem(folder, 0);
    item0.setToolTipText("TabItem \n toolTip");

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:MainClass.java

public static void main(String[] a) {
    Display d = new Display();
    Shell s = new Shell(d);

    s.setText("A Shell Menu Example");

    Menu m = new Menu(s, SWT.BAR);

    MenuItem file = new MenuItem(m, SWT.CASCADE);
    file.setText("File");
    Menu filemenu = new Menu(s, SWT.DROP_DOWN);
    file.setMenu(filemenu);/*from  w  w  w.j  ava 2s.com*/
    MenuItem openItem = new MenuItem(filemenu, SWT.PUSH);
    openItem.setText("Open");
    MenuItem exitItem = new MenuItem(filemenu, SWT.PUSH);
    exitItem.setText("Exit");

    s.setMenuBar(m);

    s.open();
    while (!s.isDisposed()) {
        if (!d.readAndDispatch())
            d.sleep();
    }
    d.dispose();

}

From source file:ShellWindowCloseEvent.java

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.addListener(SWT.Close, new Listener() {
        public void handleEvent(Event event) {
            System.out.println("cose");
        }/* ww  w  . j av a  2s .  c om*/
    });
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}