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

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

Introduction

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

Prototype

@Override
    public Color getSystemColor(int id) 

Source Link

Usage

From source file:TableColumnIcon.java

public static void main(String[] args) {
    final Display display = new Display();
    final Image image = new Image(display, 16, 16);
    GC gc = new GC(image);
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
    gc.fillRectangle(image.getBounds());
    gc.dispose();//from www . ja  v a 2s .  c o m

    final Shell shell = new Shell(display);
    shell.setText("Lazy Table");
    shell.setLayout(new FillLayout());

    final Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
    table.setSize(200, 200);

    for (int i = 0; i < 20; i++) {
        final int[] index = new int[] { i };
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText("Table Item " + index[0]);
        item.setImage(image);
    }
    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}

From source file:CanvasExample.java

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

    Image small = new Image(display, 16, 16);
    GC gc = new GC(small);
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
    gc.fillArc(0, 0, 16, 16, 45, 270);/*from   w w w. j a va2 s.c o  m*/
    gc.dispose();

    Image large = new Image(display, 32, 32);
    gc = new GC(large);
    gc.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
    gc.fillArc(0, 0, 32, 32, 45, 270);
    gc.dispose();

    /* Provide different resolutions for icons to get
     * high quality rendering wherever the OS needs 
     * large icons. For example, the ALT+TAB window 
     * on certain systems uses a larger icon.
     */
    Shell shell = new Shell(display);
    shell.setText("Small and Large icons");
    shell.setImages(new Image[] { small, large });

    /* No large icon: the OS will scale up the
     * small icon when it needs a large one.
     */
    Shell shell2 = new Shell(display);
    shell2.setText("Small icon");
    shell2.setImage(small);

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

From source file:Snippet43.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.open();//from  ww w .  ja  v  a 2 s.co  m
    Caret caret = new Caret(shell, SWT.NONE);
    Color white = display.getSystemColor(SWT.COLOR_WHITE);
    Color black = display.getSystemColor(SWT.COLOR_BLACK);
    Image image = new Image(display, 20, 20);
    GC gc = new GC(image);
    gc.setBackground(black);
    gc.fillRectangle(0, 0, 20, 20);
    gc.setForeground(white);
    gc.drawLine(0, 0, 19, 19);
    gc.drawLine(19, 0, 0, 19);
    gc.dispose();
    caret.setLocation(10, 10);
    caret.setImage(image);
    gc = new GC(shell);
    gc.drawImage(image, 10, 64);
    caret.setVisible(false);
    gc.drawString("Test", 12, 12);
    caret.setVisible(true);
    gc.dispose();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}

From source file:Snippet7.java

public static void main(String[] args) {
    final Display display = new Display();
    final Image image = new Image(display, 16, 16);
    GC gc = new GC(image);
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
    gc.fillRectangle(image.getBounds());
    gc.dispose();//from w w  w. j  a va2  s. c o  m
    final Shell shell = new Shell(display);
    shell.setText("Lazy Table");
    shell.setLayout(new FillLayout());
    final Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
    table.setSize(200, 200);
    Thread thread = new Thread() {
        public void run() {
            for (int i = 0; i < 20000; i++) {
                if (table.isDisposed())
                    return;
                final int[] index = new int[] { i };
                display.syncExec(new Runnable() {
                    public void run() {
                        if (table.isDisposed())
                            return;
                        TableItem item = new TableItem(table, SWT.NONE);
                        item.setText("Table Item " + index[0]);
                        item.setImage(image);
                    }
                });
            }
        }
    };
    thread.start();
    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}

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

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

    Image small = new Image(display, 16, 16);
    GC gc = new GC(small);
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
    gc.fillArc(0, 0, 16, 16, 45, 270);//from  w  w w  .  ja  v a2  s .  co m
    gc.dispose();

    Image large = new Image(display, 32, 32);
    gc = new GC(large);
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
    gc.fillArc(0, 0, 32, 32, 45, 270);
    gc.dispose();

    /* Provide different resolutions for icons to get
     * high quality rendering wherever the OS needs
     * large icons. For example, the ALT+TAB window
     * on certain systems uses a larger icon.
     */
    Shell shell = new Shell(display);
    shell.setText("Small and Large icons");
    shell.setImages(new Image[] { small, large });

    /* No large icon: the OS will scale up the
     * small icon when it needs a large one.
     */
    Shell shell2 = new Shell(display);
    shell2.setText("Small icon");
    shell2.setImage(small);

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

From source file:IconResolutions.java

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

    Image small = new Image(display, 16, 16);
    GC gc = new GC(small);
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
    gc.fillArc(0, 0, 16, 16, 45, 270);//from   w  w w.  j ava2s  .  c  o m
    gc.dispose();

    Image large = new Image(display, 32, 32);
    gc = new GC(large);
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
    gc.fillArc(0, 0, 32, 32, 45, 270);
    gc.dispose();

    /*
     * Provide different resolutions for icons to get high quality rendering
     * wherever the OS needs large icons. For example, the ALT+TAB window on
     * certain systems uses a larger icon.
     */
    Shell shell = new Shell(display);
    shell.setText("Small and Large icons");
    shell.setImages(new Image[] { small, large });

    /*
     * No large icon: the OS will scale up the small icon when it needs a large
     * one.
     */
    Shell shell2 = new Shell(display);
    shell2.setText("Small icon");
    shell2.setImage(small);

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

From source file:TextLayoutUnicode.java

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

    Font font1 = new Font(display, "Tahoma", 14, SWT.BOLD);

    Color blue = display.getSystemColor(SWT.COLOR_BLUE);
    Color yellow = display.getSystemColor(SWT.COLOR_YELLOW);

    final TextLayout layout = new TextLayout(display);
    TextStyle style1 = new TextStyle(font1, yellow, blue);

    layout.setText("English \u65E5\u672C\u8A9E  \u0627\u0644\u0639\u0631\u0628\u064A\u0651\u0629");
    layout.setStyle(style1, 8, 21);//w  ww  . jav  a  2  s .co  m

    shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
    shell.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event event) {
            layout.draw(event.gc, 10, 10);
        }
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    font1.dispose();
    layout.dispose();
    display.dispose();
}

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

public static void main(String[] args) {
    final Display display = new Display();
    final Image image = new Image(display, 16, 16);
    GC gc = new GC(image);
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
    gc.fillRectangle(image.getBounds());
    gc.dispose();/* ww  w. j  a v  a2  s .  c o  m*/
    final Shell shell = new Shell(display);
    shell.setText("Lazy Table");
    shell.setLayout(new FillLayout());
    final Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
    table.setSize(200, 200);
    Thread thread = new Thread() {
        @Override
        public void run() {
            for (int i = 0; i < 20000; i++) {
                if (table.isDisposed())
                    return;
                final int[] index = new int[] { i };
                display.syncExec(() -> {
                    if (table.isDisposed())
                        return;
                    TableItem item = new TableItem(table, SWT.NONE);
                    item.setText("Table Item " + index[0]);
                    item.setImage(image);
                });
            }
        }
    };
    thread.start();
    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}

From source file:Snippet47.java

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

    Image image = new Image(display, 20, 20);
    Color color = display.getSystemColor(SWT.COLOR_BLUE);
    GC gc = new GC(image);
    gc.setBackground(color);/*from   w  w w  . j ava  2s.c o  m*/
    gc.fillRectangle(image.getBounds());
    gc.dispose();

    Image disabledImage = new Image(display, 20, 20);
    color = display.getSystemColor(SWT.COLOR_GREEN);
    gc = new GC(disabledImage);
    gc.setBackground(color);
    gc.fillRectangle(disabledImage.getBounds());
    gc.dispose();

    Image hotImage = new Image(display, 20, 20);
    color = display.getSystemColor(SWT.COLOR_RED);
    gc = new GC(hotImage);
    gc.setBackground(color);
    gc.fillRectangle(hotImage.getBounds());
    gc.dispose();

    ToolBar bar = new ToolBar(shell, SWT.BORDER | SWT.FLAT);
    bar.setSize(200, 32);
    for (int i = 0; i < 12; i++) {
        ToolItem item = new ToolItem(bar, 0);
        item.setImage(image);
        item.setDisabledImage(disabledImage);
        item.setHotImage(hotImage);
        if (i % 3 == 0)
            item.setEnabled(false);
    }

    shell.open();
    bar.getItems()[1].setImage(disabledImage);
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    disabledImage.dispose();
    hotImage.dispose();
    display.dispose();
}

From source file:ToolBarNormalHotDisabledImage.java

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

    Image image = new Image(display, 20, 20);
    Color color = display.getSystemColor(SWT.COLOR_BLUE);
    GC gc = new GC(image);
    gc.setBackground(color);//from   www.ja v  a2  s . c  om
    gc.fillRectangle(image.getBounds());
    gc.dispose();

    Image disabledImage = new Image(display, 20, 20);
    color = display.getSystemColor(SWT.COLOR_GREEN);
    gc = new GC(disabledImage);
    gc.setBackground(color);
    gc.fillRectangle(disabledImage.getBounds());
    gc.dispose();

    Image hotImage = new Image(display, 20, 20);
    color = display.getSystemColor(SWT.COLOR_RED);
    gc = new GC(hotImage);
    gc.setBackground(color);
    gc.fillRectangle(hotImage.getBounds());
    gc.dispose();

    ToolBar bar = new ToolBar(shell, SWT.BORDER | SWT.FLAT);
    bar.setSize(200, 32);
    for (int i = 0; i < 12; i++) {
        ToolItem item = new ToolItem(bar, 0);
        item.setImage(image);
        item.setDisabledImage(disabledImage);
        item.setHotImage(hotImage);
        if (i % 3 == 0)
            item.setEnabled(false);
    }

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