Label WRAP style : Label « SWT « Java Tutorial






Label WRAP style
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class WrapStyleLabel {

  public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);

    String text = "This is a long long long long long long long text.";
    
    Label labelNoWrap = new Label(shell, SWT.BORDER);
    labelNoWrap.setText(text);
    labelNoWrap.setBounds(10, 10, 100, 100);
    
    Label labelWrap = new Label(shell, SWT.WRAP | SWT.BORDER);
    labelWrap.setText(text);
    labelWrap.setBounds(120, 10, 100, 100);
      
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
}








17.13.Label
17.13.1.Introducing Label
17.13.2.Label Styles
17.13.3.Add Label to ShellAdd Label to Shell
17.13.4.Use Label as a separatorUse Label as a separator
17.13.5.Label with borderLabel with border
17.13.6.Horizontal Separator LabelHorizontal Separator Label
17.13.7.Adding Image to LabelAdding Image to Label
17.13.8.Label WRAP styleLabel WRAP style
17.13.9.SHADOW_IN, SHADOW_OUT, SHADOW_NONE: These three styles specify the shadow behavior of labels with the SEPARATOR style.SHADOW_IN, SHADOW_OUT, SHADOW_NONE: These three styles specify the shadow behavior of labels with the SEPARATOR style.
17.13.10.LEFT, RIGHT, CENTER: These styles specify the text/image alignment in labels.LEFT, RIGHT, CENTER: These styles specify the text/image alignment in labels.
17.13.11.Label with border(SWT.BORDER)Label with border(SWT.BORDER)