List of usage examples for org.eclipse.swt.widgets Label setImage
public void setImage(Image image)
From source file:ImageCreateCode.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Label label = new Label(shell, SWT.NONE); label.setImage(getCheckedImage(display)); shell.open();//from ww w.j a va 2s. c o m while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet34.java
public static void main(String[] args) { Display display = new Display(); Image image = new Image(display, 16, 16); Color color = display.getSystemColor(SWT.COLOR_RED); GC gc = new GC(image); gc.setBackground(color);//from w w w . ja va 2 s . com gc.fillRectangle(image.getBounds()); gc.dispose(); Shell shell = new Shell(display); Label label = new Label(shell, SWT.BORDER); label.setImage(image); label.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } image.dispose(); display.dispose(); }
From source file:SystemIconImage.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Label label = new Label(shell, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_ERROR)); label = new Label(shell, SWT.NONE); label.setText("SWT.ICON_ERROR"); label = new Label(shell, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_INFORMATION)); label = new Label(shell, SWT.NONE); label.setText("SWT.ICON_INFORMATION"); label = new Label(shell, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_WARNING)); label = new Label(shell, SWT.NONE); label.setText("SWT.ICON_WARNING"); label = new Label(shell, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_QUESTION)); label = new Label(shell, SWT.NONE); label.setText("SWT.ICON_QUESTION"); shell.setSize(400, 350);/* w ww . jav a 2 s. c om*/ shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:LabelExample.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(); shell.setLayout(new GridLayout(1, false)); // Create a label new Label(shell, SWT.NONE).setText("This is a plain label."); // Create a vertical separator new Label(shell, SWT.SEPARATOR); // Create a label with a border new Label(shell, SWT.BORDER).setText("This is a label with a border."); // Create a horizontal separator Label separator = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR); separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Create a label with an image Image image = new Image(display, "java2s.gif"); Label imageLabel = new Label(shell, SWT.NONE); imageLabel.setImage(image); shell.open();/*from ww w. j a va2 s . c om*/ while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ExpandBarIconAddingSystem.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setText("ExpandBar Example"); ExpandBar bar = new ExpandBar(shell, SWT.V_SCROLL); Image image = new Image(display, "yourFile.gif"); // First item Composite composite = new Composite(bar, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10; layout.verticalSpacing = 10;//from www. j a v a 2s. c o m composite.setLayout(layout); Label label = new Label(composite, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_ERROR)); label = new Label(composite, SWT.NONE); label.setText("SWT.ICON_ERROR"); label = new Label(composite, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_INFORMATION)); label = new Label(composite, SWT.NONE); label.setText("SWT.ICON_INFORMATION"); label = new Label(composite, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_WARNING)); label = new Label(composite, SWT.NONE); label.setText("SWT.ICON_WARNING"); label = new Label(composite, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_QUESTION)); label = new Label(composite, SWT.NONE); label.setText("SWT.ICON_QUESTION"); ExpandItem item0 = new ExpandItem(bar, SWT.NONE, 0); item0.setText("What is your favorite button"); item0.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); item0.setControl(composite); item0.setImage(image); item0.setExpanded(true); bar.setSpacing(8); shell.setSize(400, 350); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } image.dispose(); display.dispose(); }
From source file:Snippet104.java
public static void main(String[] args) { final Display display = new Display(); final int[] count = new int[] { 4 }; final Image image = new Image(display, 300, 300); final Shell splash = new Shell(SWT.ON_TOP); final ProgressBar bar = new ProgressBar(splash, SWT.NONE); bar.setMaximum(count[0]);/* www . j a v a2s . c om*/ Label label = new Label(splash, SWT.NONE); label.setImage(image); FormLayout layout = new FormLayout(); splash.setLayout(layout); FormData labelData = new FormData(); labelData.right = new FormAttachment(100, 0); labelData.bottom = new FormAttachment(100, 0); label.setLayoutData(labelData); FormData progressData = new FormData(); progressData.left = new FormAttachment(0, 5); progressData.right = new FormAttachment(100, -5); progressData.bottom = new FormAttachment(100, -5); bar.setLayoutData(progressData); splash.pack(); Rectangle splashRect = splash.getBounds(); Rectangle displayRect = display.getBounds(); int x = (displayRect.width - splashRect.width) / 2; int y = (displayRect.height - splashRect.height) / 2; splash.setLocation(x, y); splash.open(); display.asyncExec(new Runnable() { public void run() { Shell[] shells = new Shell[count[0]]; for (int i = 0; i < count[0]; i++) { shells[i] = new Shell(display); shells[i].setSize(300, 300); shells[i].addListener(SWT.Close, new Listener() { public void handleEvent(Event e) { --count[0]; } }); bar.setSelection(i + 1); try { Thread.sleep(1000); } catch (Throwable e) { } } splash.close(); image.dispose(); for (int i = 0; i < count[0]; i++) { shells[i].open(); } } }); while (count[0] != 0) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet104.java
public static void main(String[] args) { final Display display = new Display(); final int[] count = new int[] { 4 }; final Image image = new Image(display, 300, 300); GC gc = new GC(image); gc.setBackground(display.getSystemColor(SWT.COLOR_CYAN)); gc.fillRectangle(image.getBounds()); gc.drawText("Splash Screen", 10, 10); gc.dispose();/*from www.ja v a 2 s. c om*/ final Shell splash = new Shell(SWT.ON_TOP); final ProgressBar bar = new ProgressBar(splash, SWT.NONE); bar.setMaximum(count[0]); Label label = new Label(splash, SWT.NONE); label.setImage(image); FormLayout layout = new FormLayout(); splash.setLayout(layout); FormData labelData = new FormData(); labelData.right = new FormAttachment(100, 0); labelData.bottom = new FormAttachment(100, 0); label.setLayoutData(labelData); FormData progressData = new FormData(); progressData.left = new FormAttachment(0, 5); progressData.right = new FormAttachment(100, -5); progressData.bottom = new FormAttachment(100, -5); bar.setLayoutData(progressData); splash.pack(); Rectangle splashRect = splash.getBounds(); Rectangle displayRect = display.getBounds(); int x = (displayRect.width - splashRect.width) / 2; int y = (displayRect.height - splashRect.height) / 2; splash.setLocation(x, y); splash.open(); display.asyncExec(() -> { Shell[] shells = new Shell[count[0]]; for (int i1 = 0; i1 < count[0]; i1++) { shells[i1] = new Shell(display); shells[i1].setSize(300, 300); shells[i1].addListener(SWT.Close, e -> --count[0]); bar.setSelection(i1 + 1); try { Thread.sleep(1000); } catch (Throwable e) { } } splash.close(); image.dispose(); for (int i2 = 0; i2 < count[0]; i2++) { shells[i2].setText("SWT Snippet 104 - " + (i2 + 1)); shells[i2].open(); } }); while (count[0] != 0) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet166.java
public static void main(String[] args) { Display display = new Display(); Image image1 = display.getSystemImage(SWT.ICON_WORKING); Image image2 = display.getSystemImage(SWT.ICON_QUESTION); Image image3 = display.getSystemImage(SWT.ICON_ERROR); Shell shell = new Shell(display); shell.setText("Snippet 166"); shell.setLayout(new FillLayout()); final ScrolledComposite scrollComposite = new ScrolledComposite(shell, SWT.V_SCROLL | SWT.BORDER); final Composite parent = new Composite(scrollComposite, SWT.NONE); for (int i = 0; i <= 50; i++) { Label label = new Label(parent, SWT.NONE); if (i % 3 == 0) label.setImage(image1); if (i % 3 == 1) label.setImage(image2);/*from w w w . j a v a 2s .com*/ if (i % 3 == 2) label.setImage(image3); } RowLayout layout = new RowLayout(SWT.HORIZONTAL); layout.wrap = true; parent.setLayout(layout); scrollComposite.setContent(parent); scrollComposite.setExpandVertical(true); scrollComposite.setExpandHorizontal(true); scrollComposite.addControlListener(ControlListener.controlResizedAdapter(e -> { Rectangle r = scrollComposite.getClientArea(); scrollComposite.setMinSize(parent.computeSize(r.width, SWT.DEFAULT)); })); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ScrolledCompositeCreate.java
public static void main(String[] args) { Display display = new Display(); Image image1 = display.getSystemImage(SWT.ICON_WORKING); Image image2 = display.getSystemImage(SWT.ICON_QUESTION); Image image3 = display.getSystemImage(SWT.ICON_ERROR); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final ScrolledComposite scrollComposite = new ScrolledComposite(shell, SWT.V_SCROLL | SWT.BORDER); final Composite parent = new Composite(scrollComposite, SWT.NONE); for (int i = 0; i <= 50; i++) { Label label = new Label(parent, SWT.NONE); if (i % 3 == 0) label.setImage(image1); if (i % 3 == 1) label.setImage(image2);// w w w .j a va2 s . c o m if (i % 3 == 2) label.setImage(image3); } RowLayout layout = new RowLayout(SWT.HORIZONTAL); layout.wrap = true; parent.setLayout(layout); scrollComposite.setContent(parent); scrollComposite.setExpandVertical(true); scrollComposite.setExpandHorizontal(true); scrollComposite.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { Rectangle r = scrollComposite.getClientArea(); scrollComposite.setMinSize(parent.computeSize(r.width, SWT.DEFAULT)); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:SplashScreenCreate.java
public static void main(String[] args) { final Display display = new Display(); final int[] count = new int[] { 4 }; final Image image = new Image(display, 300, 300); GC gc = new GC(image); gc.setBackground(display.getSystemColor(SWT.COLOR_CYAN)); gc.fillRectangle(image.getBounds()); gc.drawText("Splash Screen", 10, 10); gc.dispose();// w ww . ja v a 2 s.c o m final Shell splash = new Shell(SWT.ON_TOP); final ProgressBar bar = new ProgressBar(splash, SWT.NONE); bar.setMaximum(count[0]); Label label = new Label(splash, SWT.NONE); label.setImage(image); FormLayout layout = new FormLayout(); splash.setLayout(layout); FormData labelData = new FormData(); labelData.right = new FormAttachment(100, 0); labelData.bottom = new FormAttachment(100, 0); label.setLayoutData(labelData); FormData progressData = new FormData(); progressData.left = new FormAttachment(0, 5); progressData.right = new FormAttachment(100, -5); progressData.bottom = new FormAttachment(100, -5); bar.setLayoutData(progressData); splash.pack(); Rectangle splashRect = splash.getBounds(); Rectangle displayRect = display.getBounds(); int x = (displayRect.width - splashRect.width) / 2; int y = (displayRect.height - splashRect.height) / 2; splash.setLocation(x, y); splash.open(); display.asyncExec(new Runnable() { public void run() { Shell[] shells = new Shell[count[0]]; for (int i = 0; i < count[0]; i++) { shells[i] = new Shell(display); shells[i].setSize(300, 300); shells[i].addListener(SWT.Close, new Listener() { public void handleEvent(Event e) { --count[0]; } }); bar.setSelection(i + 1); try { Thread.sleep(1000); } catch (Throwable e) { } } splash.close(); image.dispose(); for (int i = 0; i < count[0]; i++) { shells[i].open(); } } }); while (count[0] != 0) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }