List of usage examples for org.eclipse.swt.widgets Display getSystemColor
@Override public Color getSystemColor(int id)
From source file:TableBackgroundTableItemForeground.java
public static void main(String[] args) { Display display = new Display(); Color red = display.getSystemColor(SWT.COLOR_RED); Color gray = display.getSystemColor(SWT.COLOR_GRAY); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table table = new Table(shell, SWT.BORDER); table.setBackground(gray);//from w w w. j a va 2 s.c o m TableColumn column1 = new TableColumn(table, SWT.NONE); TableColumn column2 = new TableColumn(table, SWT.NONE); TableColumn column3 = new TableColumn(table, SWT.NONE); TableItem item = new TableItem(table, SWT.NONE); item.setText(new String[] { "entire", "row", "red foreground" }); item.setForeground(red); column1.pack(); column2.pack(); column3.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TableItemBackground.java
public static void main(String[] args) { Display display = new Display(); Color red = display.getSystemColor(SWT.COLOR_RED); Color gray = display.getSystemColor(SWT.COLOR_GRAY); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table table = new Table(shell, SWT.BORDER); table.setBackground(gray);// ww w .j a v a2 s . co m TableColumn column1 = new TableColumn(table, SWT.NONE); TableColumn column2 = new TableColumn(table, SWT.NONE); TableColumn column3 = new TableColumn(table, SWT.NONE); TableItem item = new TableItem(table, SWT.NONE); item.setText(new String[] { "entire", "row", "red background" }); item.setBackground(red); column1.pack(); column2.pack(); column3.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ImageDataFromPaletteData.java
public static void main(String[] args) { Display display = new Display(); Color white = display.getSystemColor(SWT.COLOR_WHITE); Color black = display.getSystemColor(SWT.COLOR_BLACK); // Create a source ImageData of depth 1 (monochrome) PaletteData palette = new PaletteData(new RGB[] { white.getRGB(), black.getRGB(), }); ImageData sourceData = new ImageData(20, 20, 1, palette); for (int i = 0; i < 10; i++) { for (int j = 0; j < 20; j++) { sourceData.setPixel(i, j, 1); }/*from w w w.ja v a 2 s . c om*/ } Shell shell = new Shell(display); final Image source = new Image(display, sourceData); shell.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.drawImage(source, 0, 0, 20, 20, 60, 10, 20, 20); } }); shell.setSize(150, 150); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } source.dispose(); display.dispose(); }
From source file:CellBackground.java
public static void main(String[] args) { Display display = new Display(); Color red = display.getSystemColor(SWT.COLOR_RED); Color gray = display.getSystemColor(SWT.COLOR_GRAY); Color blue = display.getSystemColor(SWT.COLOR_BLUE); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table table = new Table(shell, SWT.BORDER); table.setBackground(gray);//w ww . j a va 2 s.c o m TableColumn column1 = new TableColumn(table, SWT.NONE); TableColumn column2 = new TableColumn(table, SWT.NONE); TableColumn column3 = new TableColumn(table, SWT.NONE); TableItem item = new TableItem(table, SWT.NONE); item.setText(new String[] { "normal", "blue background", "red background" }); item.setBackground(1, blue); item.setBackground(2, red); column1.pack(); column2.pack(); column3.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:CellForeground.java
public static void main(String[] args) { Display display = new Display(); Color red = display.getSystemColor(SWT.COLOR_RED); Color gray = display.getSystemColor(SWT.COLOR_GRAY); Color blue = display.getSystemColor(SWT.COLOR_BLUE); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table table = new Table(shell, SWT.BORDER); table.setBackground(gray);//from w ww. j a v a 2s. c o m TableColumn column1 = new TableColumn(table, SWT.NONE); TableColumn column2 = new TableColumn(table, SWT.NONE); TableColumn column3 = new TableColumn(table, SWT.NONE); TableItem item = new TableItem(table, SWT.NONE); item.setText(new String[] { "normal", "blue foreground", "red foreground" }); item.setForeground(1, blue); item.setForeground(2, red); column1.pack(); column2.pack(); column3.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ImagePaint.java
public static void main(String[] args) { Display display = new Display(); Image image = new Image(display, 20, 20); Color black = display.getSystemColor(SWT.COLOR_BLACK); GC gc = new GC(image); gc.setForeground(black);//from w ww .j ava 2 s . c o m gc.drawString("Test", 2, 2); gc.dispose(); display.dispose(); }
From source file:TextAroundBox.java
public static void main(String[] args) { final Display display = new Display(); final Color RED = display.getSystemColor(SWT.COLOR_RED); Shell shell = new Shell(display); shell.setBounds(10, 10, 250, 250);//ww w. ja v a 2s. c o m final StyledText text = new StyledText(shell, SWT.NONE); text.setBounds(10, 10, 200, 200); text.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { String contents = text.getText(); int stringWidth = event.gc.stringExtent(SEARCH_STRING).x; int lineHeight = text.getLineHeight(); event.gc.setForeground(RED); int index = contents.indexOf(SEARCH_STRING); while (index != -1) { Point topLeft = text.getLocationAtOffset(index); event.gc.drawRectangle(topLeft.x - 1, topLeft.y, stringWidth + 1, lineHeight - 1); index = contents.indexOf(SEARCH_STRING, index + 1); } } }); text.setText("This demonstrates drawing a box\naround every occurrence of the word\nbox in the StyledText"); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet70.java
public static void main(String[] args) { Display display = new Display(); Color red = display.getSystemColor(SWT.COLOR_RED); 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(red);/*from ww w . j a v a 2 s. c o m*/ gc.fillRectangle(5, 5, 10, 10); gc.dispose(); ImageData imageData = image.getImageData(); PaletteData palette = new PaletteData(new RGB(0, 0, 0), new RGB(0xFF, 0xFF, 0xFF)); ImageData maskData = new ImageData(20, 20, 1, palette); Image mask = new Image(display, maskData); gc = new GC(mask); gc.setBackground(black); gc.fillRectangle(0, 0, 20, 20); gc.setBackground(white); gc.fillRectangle(5, 5, 10, 10); gc.dispose(); maskData = mask.getImageData(); Image icon = new Image(display, imageData, maskData); Shell shell = new Shell(display); shell.setText("Snippet 70"); Button button = new Button(shell, SWT.PUSH); button.setImage(icon); button.setSize(60, 60); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } icon.dispose(); image.dispose(); mask.dispose(); display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet68.java
public static void main(String[] args) { final Display display = new Display(); final Color red = display.getSystemColor(SWT.COLOR_RED); final Color blue = display.getSystemColor(SWT.COLOR_BLUE); Shell shell = new Shell(display); shell.setText("Snippet 68"); shell.setLayout(new RowLayout()); Button button = new Button(shell, SWT.PUSH); button.setText("Stop Timer"); final Label label = new Label(shell, SWT.BORDER); label.setBackground(red);//from ww w . j a va 2 s.com final int time = 500; final Runnable timer = new Runnable() { @Override public void run() { if (label.isDisposed()) return; Color color = label.getBackground().equals(red) ? blue : red; label.setBackground(color); display.timerExec(time, this); } }; display.timerExec(time, timer); button.addListener(SWT.Selection, event -> display.timerExec(-1, timer)); button.pack(); label.setLayoutData(new RowData(button.getSize())); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:IconInMemory.java
public static void main(String[] args) { Display display = new Display(); Color red = display.getSystemColor(SWT.COLOR_RED); 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(red);//from www . j a v a2s. co m gc.fillRectangle(5, 5, 10, 10); gc.dispose(); ImageData imageData = image.getImageData(); PaletteData palette = new PaletteData(new RGB[] { new RGB(0, 0, 0), new RGB(0xFF, 0xFF, 0xFF), }); ImageData maskData = new ImageData(20, 20, 1, palette); Image mask = new Image(display, maskData); gc = new GC(mask); gc.setBackground(black); gc.fillRectangle(0, 0, 20, 20); gc.setBackground(white); gc.fillRectangle(5, 5, 10, 10); gc.dispose(); maskData = mask.getImageData(); Image icon = new Image(display, imageData, maskData); Shell shell = new Shell(display); Button button = new Button(shell, SWT.PUSH); button.setImage(icon); button.setSize(60, 60); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } icon.dispose(); image.dispose(); mask.dispose(); display.dispose(); }