HelloWorld.java

/*
 * Copyright © 2011 Nokia Corporation. All rights reserved.
 * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
 * Oracle and Java are trademarks or registered trademarks of Oracle and/or its
 * affiliates. Other product and company names mentioned herein may be trademarks
 * or trade names of their respective owners.
 * See LICENSE.TXT for license information.
 */

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ercp.swt.mobile.Command;

public class HelloWorld extends SWTMIDlet {

    public void runUI(Display display) {
        Shell shell = new Shell(display);
        Command exitCommand = new Command(shell, Command.EXIT, 0);
        exitCommand.setText("Exit");
        exitCommand.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent arg0) {
                exit();
            }

            public void widgetDefaultSelected(SelectionEvent arg0) {
            }
        });
        shell.setLayout(new FillLayout());
        Label label = new Label(shell, SWT.HORIZONTAL);
        label.setText("Hello, world!");
        shell.open();
    }
}