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

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

Introduction

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

Prototype

public boolean sleep() 

Source Link

Document

Causes the user-interface thread to sleep (that is, to be put in a state where it does not consume CPU cycles) until an event is received or it is otherwise awakened.

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);
    }/*  w w  w .  jav a2 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:WrapStyleLabel.java

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

    String text = "This is a long long long long long long long text.";

    Label labelNoWrap = new Label(shell, SWT.BORDER);
    labelNoWrap.setText(text);/*w  w w  .j  a va 2  s  . c  o  m*/
    labelNoWrap.setBounds(10, 10, 100, 100);

    Label labelWrap = new Label(shell, SWT.WRAP | SWT.BORDER);
    labelWrap.setText(text);
    labelWrap.setBounds(120, 10, 100, 100);

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

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  w  w  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 ww w .  j  a v a  2  s.com*/
 */
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.//from   www.  j a 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 w w  w .  ja  va2 s.c o  m*/
    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  w  ww .j  av  a2  s  . co  m
    setDragDrop(label2);
    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

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  2  s.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:org.eclipse.swt.snippets.Snippet120.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 120");
    shell.setSize(200, 200);//w w w  .jav  a  2s  . c om
    Monitor primary = display.getPrimaryMonitor();
    Rectangle bounds = primary.getBounds();
    Rectangle rect = shell.getBounds();
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;
    shell.setLocation(x, y);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 54");
    shell.setSize(400, 300);/*from  w  w w .  j av a 2  s  . c om*/
    final Sash sash = new Sash(shell, SWT.BORDER | SWT.VERTICAL);
    Rectangle clientArea = shell.getClientArea();
    sash.setBounds(180, clientArea.y, 32, clientArea.height);
    sash.addListener(SWT.Selection, e -> sash.setBounds(e.x, e.y, e.width, e.height));
    shell.open();
    sash.setFocus();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}