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:org.eclipse.swt.snippets.Snippet18.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 18");
    ToolBar bar = new ToolBar(shell, SWT.BORDER);
    for (int i = 0; i < 8; i++) {
        ToolItem item = new ToolItem(bar, SWT.PUSH);
        item.setText("Item " + i);
    }/*from   www  .  j  av a  2  s  .  c  o  m*/
    Rectangle clientArea = shell.getClientArea();
    bar.setLocation(clientArea.x, clientArea.y);
    bar.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:MainClass.java

public static void main(String[] a) {

    final Display d = new Display();
    final Shell shell = new Shell(d);

    shell.setSize(250, 200);/* ww w . j  av  a 2 s  . c o m*/

    shell.setLayout(new FillLayout());

    // Create a canvas
    Canvas canvas = new Canvas(shell, SWT.NONE);

    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {

            e.gc.drawRoundRectangle(10, 10, 200, 200, 30, 60);

        }
    });

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

From source file:Snippet34.java

public static void main(String[] args) {
    Display display = new Display();
    Image image = new Image(display, 16, 16);
    Color color = display.getSystemColor(SWT.COLOR_RED);
    GC gc = new GC(image);
    gc.setBackground(color);/*from  ww  w . j a v a  2 s. c o  m*/
    gc.fillRectangle(image.getBounds());
    gc.dispose();
    Shell shell = new Shell(display);
    Label label = new Label(shell, SWT.BORDER);
    label.setImage(image);
    label.pack();
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}

From source file:org.jfree.chart.swt.demo.SWTBarChartDemo1.java

/**
 * Starting point for the demonstration application.
 *
 * @param args  ignored./*from   w  w w .  j  a v a  2  s  .  c om*/
 */
public static void main(String[] args) {
    JFreeChart chart = createChart(createDataset());
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(600, 300);
    shell.setLayout(new FillLayout());
    shell.setText("Test for jfreechart running with SWT");
    ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true);
    frame.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}

From source file:org.jfree.chart.swt.demo.SWTPieChartDemo1.java

/**
 * Starting point for the demonstration application.
 *
 * @param args  ignored.//  w  ww.  ja  va 2 s  .c  o  m
 */
public static void main(String[] args) {
    JFreeChart chart = createChart(createDataset());
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(600, 400);
    shell.setLayout(new FillLayout());
    shell.setText("Test for jfreechart running with SWT");
    final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true);
    //frame.setDisplayToolTips(false);
    frame.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}

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

public static void main(String[] args) throws Exception {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 374");
    shell.setLayout(new FillLayout());
    shell.setText("Customize line vertical indent");

    StyledText text = new StyledText(shell, SWT.BORDER | SWT.V_SCROLL);
    text.setWordWrap(true);/*from   www.  j  a  va 2 s .c  om*/
    text.setText("word1 word2 word3 word4");
    text.setLineVerticalIndent(0, 20);

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

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

public static void main(String[] args) {

    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Snippet 78");
    shell.setLayout(new FillLayout());
    final Label label1 = new Label(shell, SWT.BORDER);
    label1.setText("TEXT");
    final Label label2 = new Label(shell, SWT.BORDER);
    setDragDrop(label1);//from www.j  av a2 s .c o  m
    setDragDrop(label2);
    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:ProgressBarDialog.java

public static void main(String args[]) {
    try {/*w w w.j a v a  2 s . co m*/
        Display display = Display.getDefault();
        PBDialogDemo shell = new PBDialogDemo(display, SWT.SHELL_TRIM);
        shell.open();
        shell.layout();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:cn.edu.thss.iise.bpmdemo.charts.SWTPieChartDemo1.java

/**
 * Starting point for the demonstration application.
 *
 * @param args//from  w ww.  j a v a  2s .c  om
 *            ignored.
 */
public static void main(String[] args) {
    JFreeChart chart = createChart(createDataset());
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(600, 400);
    shell.setLayout(new FillLayout());
    shell.setText("Test for jfreechart running with SWT");
    final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true);
    // frame.setDisplayToolTips(false);
    frame.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}

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);//ww 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();
        }
    }
}