List of usage examples for org.eclipse.swt.widgets Label setImage
public void setImage(Image image)
From source file:LabelSeparator.java
public LabelSeparator() { init();/*w w w .j a va2 s. c om*/ // shell.setLayout(new RowLayout()); Label label = new Label(shell, SWT.BORDER); // Label label = new Label(shell, SWT.SEPARATOR); label.setImage(image); label.setText("Label"); label.setBounds(10, 10, 150, 150); CLabel clabel = new CLabel(shell, SWT.SHADOW_IN); clabel.setImage(image); clabel.setText("CLabel"); clabel.setBounds(170, 10, 150, 150); shell.pack(); shell.open(); //textUser.forceFocus(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:ControlListenerExample.java
/** * Creates the main window's contents//from w ww . j a va2 s . c o m * * @param shell the main window * @param image the image */ private void createContents(Shell shell, Image image) { shell.setLayout(new GridLayout()); // Create a label to hold the image Label label = new Label(shell, SWT.NONE); label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); label.setImage(image); shell.setData(label); // Add the listener shell.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent event) { // Get the event source (the shell) Shell shell = (Shell) event.getSource(); // Get the source's data (the label) Label label = (Label) shell.getData(); // Determine how big the shell should be to fit the image Rectangle rect = shell.getClientArea(); ImageData data = label.getImage().getImageData(); // If the shell is too small, hide the image if (rect.width < data.width || rect.height < data.height) { shell.setText("Too small."); label.setText("I'm melting!"); } else { // He fits! shell.setText("Happy Guy Fits!"); label.setImage(label.getImage()); } } }); }
From source file:com.android.ddmuilib.HeapPanel.java
private void createLegend(Composite parent) { mLegend = new Group(parent, SWT.NONE); mLegend.setText(getLegendText(0));/* w w w. ja va2s.co m*/ mLegend.setLayout(new GridLayout(2, false)); RGB[] colors = mMapPalette.colors; for (int i = 0; i < NUM_PALETTE_ENTRIES; i++) { Image tmpImage = createColorRect(parent.getDisplay(), colors[i]); Label l = new Label(mLegend, SWT.NONE); l.setImage(tmpImage); l = new Label(mLegend, SWT.NONE); l.setText(mMapLegend[i]); } }