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

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

    FileDialog dlg = new FileDialog(shell, SWT.OPEN);
    String fileName = dlg.open();
    if (fileName != null) {
        System.out.println(fileName);
    }/*from   ww  w.j  a v  a2 s  .  c  o m*/

    display.dispose();

}

From source file:StyledTextCreate.java

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

    StyledText text = new StyledText(shell, SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);

    text.setBounds(10, 10, 100, 100);//from  w ww .j  a v  a  2 s .c o m

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

}

From source file:WidgetBoundsSetting.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setBounds(10, 10, 200, 200);/*  w  ww .  j  a  va 2 s.  com*/

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("&Typical button");
    button1.setBounds(10, 10, 180, 30);
    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("&Overidden button");
    button2.setBounds(10, 50, 180, 30);

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

From source file:ControlBounds.java

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

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

    button.setBounds(20, 20, 200, 20);//from  w w w. jav  a  2s .co m

    shell.setSize(260, 120);
    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:ShellApplicationModal.java

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

    shell.open();/*from  ww  w.jav a 2  s .  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:DialogShellPositionIt.java

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

    Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    Point pt = display.getCursorLocation();
    dialog.setLocation(pt.x, pt.y);/* w  w w .  j  a  v a  2s . c  o  m*/
    dialog.setText("Dialog Shell");
    dialog.setSize(100, 100);
    dialog.open();

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

From source file:StyledTextLimit.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.setTextLimit(10);//from  w  w w  . j  a  v a 2s .  co  m

    styledText.setBounds(10, 10, 100, 100);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:StyledTextWordWrap.java

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

    StyledText text1 = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);

    text1.setWordWrap(!text1.getWordWrap());

    text1.setBounds(10, 10, 100, 100);/* w  ww. j  a va2s.c om*/
    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 v a2s.c  om*/
    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:StyledTextTabSize.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.setTabs(2);//from w ww.j av  a 2 s  .  c  o m

    styledText.setBounds(10, 10, 100, 100);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}