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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Button button = new Button(shell, SWT.PUSH);
    button.setText("No layout");
    button.setBounds(new Rectangle(5, 5, 100, 100));
    shell.pack();//  w w  w  . ja v a2s  . c o m
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:MouseTrackListenerUsing.java

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

    shell.addMouseTrackListener(new MouseTrackListener() {

        public void mouseEnter(MouseEvent arg0) {
            System.out.println("mouseEnter");

        }/*from   w  w  w . j a  va 2  s  . c om*/

        public void mouseExit(MouseEvent arg0) {
            System.out.println("mouseExit");

        }

        public void mouseHover(MouseEvent arg0) {
            System.out.println("mouseHover");

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

From source file:RowLayoutType.java

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

    RowLayout rowLayout = new RowLayout();
    rowLayout.type = SWT.VERTICAL;/*from  w w w.  j a  v a2s .  c  o  m*/

    shell.setLayout(rowLayout);

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");

    List list = new List(shell, SWT.BORDER);
    list.add("item 1");
    list.add("item 2");
    list.add("item 3");

    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("button #2");

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

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

From source file:RowLayoutFill.java

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

    RowLayout rowLayout = new RowLayout();
    rowLayout.fill = true; // Overriding default values.

    shell.setLayout(rowLayout);//w  w  w  .j  a  va2s .c o  m

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");

    List list = new List(shell, SWT.BORDER);
    list.add("item 1");
    list.add("item 2");
    list.add("item 3");

    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("button #2");

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

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

From source file:RowLayoutWrap.java

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

    RowLayout rowLayout = new RowLayout();
    rowLayout.wrap = false;//  ww w.j  av  a  2 s  .  com

    shell.setLayout(rowLayout);

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");

    List list = new List(shell, SWT.BORDER);
    list.add("item 1");
    list.add("item 2");
    list.add("item 3");

    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("button #2");

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

    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();
    final Shell s = new Shell(d);

    s.setSize(250, 200);/*from   w ww  . ja  v a  2s.co  m*/
    s.setText("A MouseListener Example");
    s.open();

    s.addMouseListener(new MouseListener() {
        public void mouseDown(MouseEvent e) {
            System.out.println("Mouse Button Down at:" + e.x + " " + e.y);

        }

        public void mouseUp(MouseEvent e) {
            System.out.println("Mouse Button up at:" + e.x + " " + e.y);
            System.out.println(e.button);

        }

        public void mouseDoubleClick(MouseEvent e) {
            System.out.println("Mouse Double Clicked at:" + e.x + " " + e.y);
        }
    });

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

}

From source file:MainClass.java

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

    // Create a List with a vertical scroll bar
    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");
    }//w  w  w  .j  a v  a  2s  . c o m

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

    // Get the scroll bar
    ScrollBar sb = list.getVerticalBar();

    // Add one more item that shows the selection value
    list.add("Selection: " + sb.getSelection());

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

From source file:RowLayoutJustify.java

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

    RowLayout rowLayout = new RowLayout();
    rowLayout.justify = true;/*from w w  w.j a  v  a 2  s  .c om*/

    shell.setLayout(rowLayout);

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");

    List list = new List(shell, SWT.BORDER);
    list.add("item 1");
    list.add("item 2");
    list.add("item 3");

    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("button #2");

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

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

From source file:RowLayoutSpacing.java

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

    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 40;/*from w ww .jav  a2 s. c  o m*/

    shell.setLayout(rowLayout);

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");

    List list = new List(shell, SWT.BORDER);
    list.add("item 1");
    list.add("item 2");
    list.add("item 3");

    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("button #2");

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

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

From source file:MenuItemDiabled.java

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

    Menu menuBar = new Menu(shell, SWT.BAR);

    Menu fileMenu = new Menu(menuBar);

    MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE | SWT.NO_RADIO_GROUP);
    fileItem.setText("File");
    fileItem.setMenu(fileMenu);/*w ww .  j ava2  s  .  com*/

    MenuItem itema = new MenuItem(fileMenu, SWT.NONE);
    itema.setText("Radio A");
    itema.setEnabled(false);
    MenuItem itemb = new MenuItem(fileMenu, SWT.NONE);
    itemb.setText("Radio B");
    MenuItem itemc = new MenuItem(fileMenu, SWT.NONE);
    itemc.setText("Radio C");

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