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

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

Introduction

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

Prototype

public static Display getCurrent() 

Source Link

Document

Returns the display which the currently running thread is the user-interface thread for, or null if the currently running thread is not a user-interface thread for any display.

Usage

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();//from w w  w .  j av  a 2  s .  c  o  m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:MainClass.java

public static void main(String[] args) {

    ApplicationWindow w = new MainClass();

    w.setBlockOnOpen(true);/*  w ww  . j  a  v a  2 s.c  o m*/

    w.open();

    Display.getCurrent().dispose();
}

From source file:CompViewer.java

public static void main(String[] args) {
    CompViewer cv = new CompViewer();
    cv.setBlockOnOpen(true);
    cv.open();
    Display.getCurrent().dispose();
}

From source file:WidgetWindow.java

public static void main(String[] args) {
    WidgetWindow wwin = new WidgetWindow();
    wwin.setBlockOnOpen(true);// www . j av a2 s  . co  m
    wwin.open();
    Display.getCurrent().dispose();
}

From source file:StyledTextLineBackgroundListener.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.addLineBackgroundListener(new LineBackgroundListener() {

        public void lineGetBackground(LineBackgroundEvent event) {
            if (event.lineText.indexOf("SWT") > -1) {
                event.lineBackground = Display.getCurrent().getSystemColor(SWT.COLOR_BLUE);
            }//w  w  w. j  a v a  2  s . com

        }
    });

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

From source file:HelloSWT_JFace.java

public static void main(String[] args) {
    HelloSWT_JFace awin = new HelloSWT_JFace();
    awin.setBlockOnOpen(true);/*from  w  w  w. j  av a  2s  .c o m*/
    awin.open();
    Display.getCurrent().dispose();
}

From source file:Ch4_Contributions.java

public static void main(String[] args) {
    Ch4_Contributions swin = new Ch4_Contributions();
    swin.setBlockOnOpen(true);//from ww w  . j av  a 2s .c om
    swin.open();
    Display.getCurrent().dispose();
}

From source file:SWTCoolBarTestDemo.java

public static void main(String[] args) {
    // --- Display SWTCoolBarTestDemo until the window is closed. ---

    SWTCoolBarTestDemo app = new SWTCoolBarTestDemo();
    app.setBlockOnOpen(true);/*from  w ww .  j av  a 2s. co  m*/
    app.open();
    Display.getCurrent().dispose();
}

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

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Snippet 352");
    shell.setLayout(new FillLayout(SWT.HORIZONTAL));
    shell.setText("Touch demonstration");

    TouchListener tl = e -> {/* w w  w  . jav  a 2s  .  c  o m*/

        Touch touches[] = e.touches;

        for (int i = 0; i < touches.length; i++) {
            Touch currTouch = touches[i];

            if ((currTouch.state & (SWT.TOUCHSTATE_UP)) != 0) {
                touchLocations.remove(currTouch.id);
            } else {
                CircleInfo info = touchLocations.get(currTouch.id);
                Point newPoint = Display.getCurrent().map(null, (Control) e.widget,
                        new Point(currTouch.x, currTouch.y));

                if (info == null) {
                    info = new CircleInfo(newPoint,
                            display.getSystemColor((colorIndex + 2) % PAINTABLE_COLORS));
                    colorIndex++;
                }

                info.center = newPoint;
                touchLocations.put(currTouch.id, info);
            }
        }

        Control c = (Control) e.widget;
        c.redraw();
    };

    PaintListener pl = e -> {
        for (CircleInfo ci : touchLocations.values()) {
            e.gc.setBackground(ci.color);
            e.gc.fillOval(ci.center.x - CIRCLE_RADIUS, ci.center.y - CIRCLE_RADIUS, CIRCLE_RADIUS * 2,
                    CIRCLE_RADIUS * 2);
        }
    };

    Canvas c = new Canvas(shell, SWT.NONE);
    c.setTouchEnabled(true);
    c.setSize(800, 800);
    c.addTouchListener(tl);
    c.addPaintListener(pl);

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

From source file:Explorer.java

public static void main(String[] args) {
    Explorer w = new Explorer();
    w.setBlockOnOpen(true);
    w.open();
    Display.getCurrent().dispose();
}