Example usage for org.eclipse.swt.widgets Label Label

List of usage examples for org.eclipse.swt.widgets Label Label

Introduction

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

Prototype

public Label(Composite parent, int style) 

Source Link

Document

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Usage

From source file:LabelShadowInOut.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display, SWT.SHELL_TRIM);
    shell.setLayout(new FillLayout());

    Label label = new Label(shell, SWT.BORDER | SWT.SHADOW_OUT);
    label.setText("text on the label");

    shell.open();//from   ww  w.jav a 2 s . co  m
    // 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:LabelTextImageAlignment.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display, SWT.SHELL_TRIM);
    shell.setLayout(new FillLayout());

    Label label = new Label(shell, SWT.BORDER | SWT.RIGHT);
    label.setText("text on the label");

    shell.open();//  w w w  .  ja  va2 s  . c  om
    // 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:EventListenerGeneral.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Label label = new Label(shell, SWT.SHADOW_IN | SWT.CENTER);

    shell.setLayout(new GridLayout());

    Listener listener = new MouseEnterExitListener();

    label.setText("Point your cursor here ...");
    label.setBounds(30, 30, 200, 30);//from   w  ww . j av  a  2s.c  o m

    label.addListener(SWT.MouseEnter, listener);
    label.addListener(SWT.MouseExit, listener);

    shell.setSize(260, 120);
    shell.open();

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

From source file:MouseTrackAdapter.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Label label = new Label(shell, SWT.SHADOW_IN | SWT.CENTER);

    shell.setLayout(new GridLayout());

    MouseTrackAdapter listener = new MouseEnterExitListener();

    label.setText("Point your cursor here ...");
    label.setBounds(30, 30, 200, 30);// w  w  w.  j  av a2 s.  com

    label.addMouseTrackListener(listener);

    shell.setSize(260, 120);
    shell.open();

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

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 w  w w. j  ava 2  s.  c o  m*/
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }

    display.dispose();
}

From source file:HorizontalSeparatorLabelExample.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell();
    shell.setLayout(new GridLayout(1, false));

    // Create a horizontal separator
    Label separator = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    shell.open();//w  ww.j  av  a 2s  . co m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:MainClass.java

public static void main(String[] a) {
    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, "interspatial.gif");
    //    Label imageLabel = new Label(shell, SWT.NONE);
    //    imageLabel.setImage(image);

    shell.open();//from  w w w. j  a va  2 s . c  o m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:MainClass.java

public static void main(String[] a) {
    Display d = new Display();
    Shell s = new Shell(d);

    s.setSize(250, 250);/*from  w ww .j  a  va 2 s  . co m*/

    s.setText("A GridLayout Example");
    GridLayout gl = new GridLayout();
    gl.numColumns = 3;
    s.setLayout(gl);
    Label l1 = new Label(s, SWT.BORDER);
    l1.setText("Column One");
    final Label l2 = new Label(s, SWT.BORDER);
    l2.setText("Column Two");
    final Label l3 = new Label(s, SWT.BORDER);
    l3.setText("Column Three");
    Text t1 = new Text(s, SWT.SINGLE | SWT.BORDER);
    Text t2 = new Text(s, SWT.SINGLE | SWT.BORDER);
    Text t3 = new Text(s, SWT.SINGLE | SWT.BORDER);
    Text t4 = new Text(s, SWT.SINGLE | SWT.BORDER);
    Text t5 = new Text(s, SWT.SINGLE | SWT.BORDER);
    Text t6 = new Text(s, SWT.SINGLE | SWT.BORDER);

    s.open();
    while (!s.isDisposed()) {
        if (!d.readAndDispatch())
            d.sleep();
    }
    d.dispose();
}

From source file:SystemFileIconLoad.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);
    Image image = null;/*w  w w .j a v a 2s  .c  o m*/

    Program p = Program.findProgram(".txt");
    ImageData data = p.getImageData();
    image = new Image(display, data);
    label.setImage(image);

    p = Program.findProgram(".bmp");
    data = p.getImageData();
    image = new Image(display, data);
    label = new Label(shell, SWT.NONE);
    label.setImage(image);

    p = Program.findProgram(".doc");
    data = p.getImageData();
    image = new Image(display, data);
    label = new Label(shell, SWT.NONE);
    label.setImage(image);

    label.pack();
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    if (image != null)
        image.dispose();
    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);/*w ww .  j  av  a  2 s . co  m*/

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