WidgetStyle.java Source code

Java tutorial

Introduction

Here is the source code for WidgetStyle.java

Source

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class WidgetStyle {

    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());

        if ((label.getStyle() & SWT.CENTER) != 1) {
            System.out.println("center");
        } else {
            System.out.println("not center");
        }

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

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

}