Demonstrates Labels : Label « SWT JFace Eclipse « Java






Demonstrates Labels

Demonstrates Labels

//Send questions, comments, bug reports, etc. to the authors:

//Rob Warner (rwarner@interspatial.com)
//Robert Harris (rbrt_harris@yahoo.com)

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.graphics.*;

/**
 * This class demonstrates Labels
 */
public class LabelExample {
  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();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}

           
       








Related examples in the same category

1.First SWT: LabelFirst SWT: Label
2.SWT Label With TextSWT Label With Text
3.Label Highlighting 3Label Highlighting 3
4.Label HighlightingLabel Highlighting
5.Label Highlighting 2Label Highlighting 2
6.CLabel BorderCLabel Border
7.CLabel Gradient Background CLabel Gradient Background
8.Label SeparatorLabel Separator
9.Label WrapLabel Wrap
10.Text and Label demoText and Label demo
11.Formatted TextFormatted Text
12.Demonstrates CLabel gradientsDemonstrates CLabel gradients
13.Demonstrates CLabel 2Demonstrates CLabel 2
14.Demonstrates CLabelDemonstrates CLabel
15.Create a label (a separator)Create a label (a separator)
16.Create a label (with an image)Create a label (with an image)
17.how to resize the Label when the Shell resizes using a Listener mechanismhow to resize the Label when the Shell resizes using a Listener mechanism
18.How to resize the Label when the Shell resizes using a LayoutHow to resize the Label when the Shell resizes using a Layout