The HelloWorld SWT

来源:互联网 发布:分享淘宝零食店铺论文 编辑:程序博客网 时间:2024/06/06 16:59

 

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

public class Test
{
    
public static void main(String[] args)
    
{
    Display display 
= new Display();

    
/*
         * Create a Shell with the default style i.e. full screen, no decoration
         * on PocketPC. Alternative: 'new Shell(display, SWT.CLOSE)' to get the
         * Pocket PC 'Ok' button.
         
*/

    Shell shell 
= new Shell(display);

    
/*
         * Set a text so that the top level Shell also appears in the Pocket PC
         * task list
         
*/

    shell.setText(
"HelloWorld");

    
/*
         * Set a menubar to follow UI guidelines on Pocket PC
         
*/

    Menu mb 
= new Menu(shell, SWT.BAR);
    shell.setMenuBar(mb);

    
/*
         * Add widgets
         
*/

    FillLayout layout 
= new FillLayout();
    layout.type 
= SWT.VERTICAL;
    shell.setLayout(layout);
    Label label 
= new Label(shell, SWT.CENTER);
    label.setText(
"Hello World");

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

    }

}