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

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

Introduction

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

Prototype

public boolean readAndDispatch() 

Source Link

Document

Reads an event from the event queue, dispatches it appropriately, and returns true if there is potentially more work to do, or false if the caller can sleep until another event is placed on the event queue.

Usage

From source file:CreateSingleSelectionListAddItems.java

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

    // Create a single-selection list
    List single = new List(shell, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);

    // Add the items, one by one
    for (int i = 0, n = ITEMS.length; i < n; i++) {
        single.add(ITEMS[i]);// w ww .  j  a va  2  s  .co  m
    }

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

From source file:MainClass.java

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

    PrintDialog dlg = new PrintDialog(shell);
    PrinterData printerData = dlg.open();
    if (printerData != null) {

        System.out.println(printerData.printToFile);

        // Printer printer = new Printer(printerData);
        // Use printer . . .
        // printer.dispose();
    }/*from   w  w  w  .  j  a  v a  2 s .  c  o m*/

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

From source file:ImageRegistryUsing.java

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

    ImageRegistry ir = new ImageRegistry();
    ir.put("image1", new Image(display, "yourFile.gif"));

    Button executeButton = new Button(shell, SWT.PUSH);
    executeButton.setText("Execute");
    executeButton.setImage(ir.get("image1"));

    shell.open();/*from w w  w.ja v a2s .  c  o m*/
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:StyledTextLineBackground.java

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

    final StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("\n1234\n124\n\1234\n12314\n\1241234\n");

    styledText.setLineBackground(0, 6, Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));

    styledText.setBounds(10, 10, 500, 100);
    shell.open();/* w w  w.j  ava 2  s  .  c  om*/
    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.setSize(250, 250);//w w w.  j  a v  a  2s.c  om

    s.setText("A RowLayout Example");
    s.setLayout(new RowLayout());
    final Text t = new Text(s, SWT.SINGLE | SWT.BORDER);
    final Button b = new Button(s, SWT.BORDER);
    final Button b1 = new Button(s, SWT.BORDER);
    b.setText("OK");
    b1.setText("Cancel");

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

From source file:org.eclipse.swt.snippets.Snippet206.java

public static void main(String[] args) {
    Display display = new Display();
    Image image = display.getSystemImage(SWT.ICON_QUESTION);
    Shell shell = new Shell(display);
    shell.setText("Snippet 206");
    shell.setLayout(new GridLayout());
    Button button = new Button(shell, SWT.PUSH);
    button.setImage(image);//from w  w  w .  j a  v a 2s  . c  om
    button.setText("Button");
    shell.setSize(300, 300);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:DrawOval.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent event) {
            Rectangle rect = shell.getClientArea();
            event.gc.drawOval(0, 0, rect.width - 1, rect.height - 1);
        }//from   ww w.ja  v a  2s. co  m
    });
    shell.setBounds(10, 10, 200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:MainClass.java

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

    PrintDialog dlg = new PrintDialog(shell);

    dlg.setScope(PrinterData.SELECTION);

    PrinterData printerData = dlg.open();
    if (printerData != null) {
        Printer printer = new Printer(printerData);
        System.out.println(printer.getClientArea());
        printer.dispose();/*from   w w w.  jav a 2s  . co m*/
    }

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

From source file:org.eclipse.swt.snippets.Snippet19.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 19");
    Text text = new Text(shell, SWT.BORDER | SWT.V_SCROLL);
    Rectangle clientArea = shell.getClientArea();
    text.setBounds(clientArea.x + 10, clientArea.y + 10, 200, 200);
    text.addVerifyListener(Snippet19::ensureTextContainsOnlyDigits);
    shell.open();//from   w  w w.  j a va 2s .  c  o  m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:FormLayoutAttachControl.java

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

    shell.setLayout(new FormLayout());

    FormData formData = new FormData();
    formData.left = new FormAttachment(50);

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");
    button1.setLayoutData(formData);//from  ww w .  j  ava2 s  .  co  m

    shell.setSize(450, 400);
    shell.open();

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