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:GCBackgroundForeground.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.open();//from  w w  w .j  ava2s  .  c  om

    Color white = display.getSystemColor(SWT.COLOR_WHITE);
    Color black = display.getSystemColor(SWT.COLOR_BLACK);

    GC gc = new GC(shell);
    gc.setBackground(black);
    gc.setForeground(white);

    gc.drawString("Test", 12, 12);

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

    display.dispose();
}

From source file:ControlSizeLocation.java

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

    shell.setSize(260, 120);/*  w w  w. j  a  v a  2s. c  o  m*/
    shell.open();

    System.out.println("------------------------------");
    System.out.println("getBounds: " + button.getBounds());
    System.out.println("getLocation: " + button.getLocation());
    System.out.println("getSize: " + button.getSize());

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

From source file:ListCreateAddItemsToIt.java

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

    // Create a List with a vertical ScrollBar
    List list = new List(shell, SWT.V_SCROLL);

    // Add a bunch of items to it
    for (int i = 0; i < 500; i++) {
        list.add("A list item");
    }//from ww  w.  j  a v a  2s.  c  o  m

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

From source file:SystemSettingChangeListener.java

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    display.addListener(SWT.Settings, new Listener() {
        public void handleEvent(Event event) {
            System.out.println("Setting changed");
        }/*w w w .  j  a  va2s  . co m*/
    });

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

From source file:ButtonAlignment.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());

    Button button = new Button(shell, SWT.RIGHT);

    button.setText("text on the button");

    button.setAlignment(SWT.CENTER);/*from  w w  w  . ja v a  2s  .c o m*/

    shell.open();
    // 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:TableItemInsertByIndex.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);// w w w. j  av a2 s  .c  o m
    for (int i = 0; i < 12; i++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText("Item " + i);
    }

    TableItem item = new TableItem(table, SWT.NONE, 5);
    item.setText(" New Item ");
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:ListScrollBottom.java

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

    // Create a List with a vertical ScrollBar
    List list = new List(shell, SWT.V_SCROLL);

    // Add a bunch of items to it
    for (int i = 0; i < 500; i++) {
        list.add("A list item");
    }/*www .  ja  va2 s . c  o  m*/

    // Scroll to the bottom
    list.select(list.getItemCount() - 1);
    list.showSelection();

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

From source file:ButtonTextAlignment.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());

    Button button = new Button(shell, SWT.RIGHT);

    button.setText("text on the button");

    shell.open();// www  . j  ava 2s  .c  om
    // 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:LabelTextImageAlignment.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.RIGHT);
    label.setText("text on the label");

    shell.open();//from www  .j av a2s . c o  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:SliderMinMaxValue.java

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

    // 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);// w w  w. j ava 2  s  . c  o m
    slider.setMaximum(100);
    slider.setIncrement(5);
    slider.setPageIncrement(20);
    slider.setSelection(75);

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