Eclipse大本营


SWT开发 - Label的使用(3)

2008-01-22 00:36Update

eclipse

本文介绍使用SWT开发一个简单的窗口程序,该窗口程序将显示一个一般的文本Label。这是Label的最一般的用法。

代码:LabelSample03.java
package com.test.swt;

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

public class LabelSample03 {
    public static void main (String[] args) {
        Display display = new Display ();
        Shell shell = new Shell (display);
        shell.setLayout (new FillLayout ());
        Label label = new Label (shell, SWT.NULL);
        label.setText("Hello Label");
        label.setToolTipText("Hello Lable ToolTipText");
        
        shell.setSize (200, 200);
        shell.open ();
        while (!shell.isDisposed ()) {
            if (!display.readAndDispatch ()) display.sleep ();
        }
        display.dispose ();
    }
}


例子比较简单,这里、不加说明了。

编译执行后显示:
 
Copyright ©2006-2010 lifevv.com. All Rights Reserved
POWERED BY @pmplat.syboos.com