SWT的ExpandBar的使用

import org.eclipse.jface.resource.JFaceResources;  
import org.eclipse.swt.SWT;  
import org.eclipse.swt.graphics.Font;  
import org.eclipse.swt.layout.FillLayout;  
import org.eclipse.swt.layout.GridLayout;  
import org.eclipse.swt.widgets.Composite;  
import org.eclipse.swt.widgets.Display;  
import org.eclipse.swt.widgets.ExpandBar;  
import org.eclipse.swt.widgets.ExpandItem;  
import org.eclipse.swt.widgets.Label;  
import org.eclipse.swt.widgets.Link;  
import org.eclipse.swt.widgets.Shell;  
public class TestExpandBar {  
    public TestExpandBar() {  
        final Display display = Display.getDefault();  
        final Shell shell = new Shell(SWT.MIN);  
        shell.setText("ExpandBar练习");  
        shell.setSize(200, 518);  
        shell.setLayout(new FillLayout());  
        ExpandBar expandBar = new ExpandBar(shell, SWT.V_SCROLL);  
        {  
            Composite comp1 = new Composite(expandBar, SWT.NONE);  
            comp1.setLayout(new GridLayout(2, false));  
            new Link(comp1, SWT.NONE).setText("<a>查看系统信息</a>");  
            new Link(comp1, SWT.NONE).setText("<a>添加/删除程序</a>");  
            new Link(comp1, SWT.NONE).setText("<a>更改一个设置</a>");  
            ExpandItem item1 = new ExpandItem(expandBar, SWT.NONE);  
            item1.setText("系统任务");  
            item1.setHeight(75);// 设置Item的高度  
            item1.setControl(comp1);// setControl方法控制comp1的显现  
        }  
        {  
            Composite comp2 = new Composite(expandBar, SWT.NONE);  
            comp2.setLayout(new GridLayout(2, false));  
            new Link(comp2, SWT.NONE).setText("<a>网上邻居</a>");  
            new Link(comp2, SWT.NONE).setText("<a>我的文档</a>");  
            new Link(comp2, SWT.NONE).setText("<a>共享文档</a>");  
            new Link(comp2, SWT.NONE).setText("<a>控制面板</a>");  
            ExpandItem item1 = new ExpandItem(expandBar, SWT.NONE);  
            item1.setText("其他位置");  
            item1.setHeight(95);// 设置Item的高度  
            item1.setControl(comp2);// setControl方法控制comp1的显现  
        }  
        {  
            Composite comp3 = new Composite(expandBar, SWT.NONE);  
            comp3.setLayout(new GridLayout());  
            // setup bold font  
            Font boldFont = JFaceResources.getFontRegistry().getBold(  
                    JFaceResources.DEFAULT_FONT);  
            Label l = new Label(comp3, SWT.NONE);  
            l.setText("我的电脑");  
            l.setFont(boldFont);  
            new Label(comp3, SWT.NONE).setText("系统文件夹");  
            ExpandItem item1 = new ExpandItem(expandBar, SWT.NONE);  
            item1.setText("详细信息");  
            item1.setHeight(50);// 设置Item的高度  
            item1.setControl(comp3);// setControl方法控制comp1的显现  
        }  
    //  shell.layout();  
        shell.open();  
        while (!shell.isDisposed()) {  
            if (!display.readAndDispatch())  
                display.sleep();  
        }  
        display.dispose();  
    }  
    public static void main(String[] args) {  
        new TestExpandBar();  
    }  


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/naughty610/archive/2010/02/16/5309552.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值