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: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);

    // create a file menu and add an exit item
    final MenuItem file = new MenuItem(m, SWT.CASCADE);
    file.setText("File");
    final Menu filemenu = new Menu(s, SWT.DROP_DOWN);
    file.setMenu(filemenu);/*  ww w .  j  a v a 2s.c  o m*/
    final MenuItem openItem = new MenuItem(filemenu, SWT.PUSH);
    openItem.setText("Open");
    final MenuItem separator = new MenuItem(filemenu, SWT.SEPARATOR);
    final 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:ToolItemRadioButton.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    ToolBar bar = new ToolBar(shell, SWT.BORDER | SWT.VERTICAL);
    for (int i = 0; i < 4; i++) {
        ToolItem item = new ToolItem(bar, SWT.RADIO);
        item.setText("Item " + i);
    }/*from   w  w  w.j  ava2s .  c om*/
    bar.pack();

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

From source file:ShellStyleTrimTool.java

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.TOOL);

    shell.setLayout(new GridLayout());

    Button button = new Button(shell, SWT.PUSH | SWT.LEFT);
    button.setText("Button");

    shell.open();//from w  ww.  jav  a  2  s . com
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}

From source file:LabelShadowInOut.java

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

    Label label = new Label(shell, SWT.BORDER | SWT.SHADOW_OUT);
    label.setText("text on the label");

    shell.open();/*from  www. ja  v  a2  s  .  co m*/
    // Set up the event loop.
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            // If no more entries in event queue
            display.sleep();
        }
    }
    display.dispose();
}

From source file:MessageBoxInformationIcon.java

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

    int style = SWT.ICON_INFORMATION;

    MessageBox messageBox = new MessageBox(shell, style);
    messageBox.setMessage("Message");
    int rc = messageBox.open();

    switch (rc) {
    case SWT.OK:/*from   ww w  . j  a va  2  s. c o  m*/
        System.out.println("SWT.OK");
        break;
    case SWT.CANCEL:
        System.out.println("SWT.CANCEL");
        break;
    case SWT.YES:
        System.out.println("SWT.YES");
        break;
    case SWT.NO:
        System.out.println("SWT.NO");
        break;
    case SWT.RETRY:
        System.out.println("SWT.RETRY");
        break;
    case SWT.ABORT:
        System.out.println("SWT.ABORT");
        break;
    case SWT.IGNORE:
        System.out.println("SWT.IGNORE");
        break;
    }

    display.dispose();
}

From source file:MainClass.java

public static void main(String[] a) {

    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(1, false));

    // Create a horizontal slider, accepting the defaults
    new Slider(shell, SWT.HORIZONTAL);

    // Create a vertical slider and set its properties
    Slider slider = new Slider(shell, SWT.VERTICAL);
    slider.setMinimum(0);/*from  www  .j a v a 2 s  . com*/
    slider.setMaximum(100);
    slider.setIncrement(5);
    slider.setPageIncrement(20);
    slider.setSelection(75);

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

From source file:TableScrollSelection.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
    table.setSize(200, 200);//from   w  ww  .j a  v  a2s.co m
    for (int i = 0; i < 128; i++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText("Item " + i);
    }
    table.setSelection(95);
    shell.pack();
    shell.open();

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

From source file:WidgetStyle.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Label label = new Label(shell, SWT.SHADOW_IN | SWT.CENTER);

    shell.setLayout(new GridLayout());

    if ((label.getStyle() & SWT.CENTER) != 1) {
        System.out.println("center");
    } else {/*  w w w .  j av  a2 s .c  o  m*/
        System.out.println("not center");
    }

    shell.setSize(260, 120);
    shell.open();

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

From source file:GetPreferredSize.java

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

    shell.setLayout(new GridLayout());

    Button button = new Button(shell, SWT.PUSH | SWT.LEFT);
    button.setText("Button");

    System.out.println("toControl: " + button.toControl(100, 200));

    shell.open();/*from   w w w.  j  a  va 2 s  . com*/
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}

From source file:StyledTextSetKeyBinding.java

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

    StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("12345");

    styledText.setKeyBinding('i' | SWT.ALT, ST.TOGGLE_OVERWRITE);

    styledText.setBounds(10, 10, 100, 100);
    shell.open();//  w  ww.j a  va2s. c  o  m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}