SWT/Jface ExpandBar使用
来源:互联网 发布:dbc2000建不了数据库 编辑:程序博客网 时间:2024/05/17 23:49
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
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 WindowStyle {
public WindowStyle() {
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 Label(comp1,SWT.NONE).setImage(new Image(display,"icons/default.gif"));
new Link(comp1,SWT.NONE).setText("<a>查看系统信息</a>");
new Label(comp1,SWT.NONE).setImage(new Image(display,"icons/doc.gif"));
new Link(comp1,SWT.NONE).setText("<a>添加/删除程序</a>");
new Label(comp1,SWT.NONE).setImage(new Image(display,"icons/main.gif"));
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 Label(comp2,SWT.NONE).setImage(new Image(display,"icons/computer.gif"));
new Link(comp2,SWT.NONE).setText("<a>网上邻居</a>");
new Label(comp2,SWT.NONE).setImage(new Image(display,"icons/inc.gif"));
new Link(comp2,SWT.NONE).setText("<a>我的文档</a>");
new Label(comp2,SWT.NONE).setImage(new Image(display,"icons/folder.gif"));
new Link(comp2,SWT.NONE).setText("<a>共享文档</a>");
new Label(comp2,SWT.NONE).setImage(new Image(display,"icons/cmd.gif"));
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 WindowStyle();
}
}
以上程序中会用到7个icon小图片,把他们放置在工程根目录下的icons目录下
运行效果:
转载自:http://hi.baidu.com/btb368/item/752412477a55eeea1f19bc61
- SWT/Jface ExpandBar使用
- SWT的ExpandBar的使用
- SWT的ExpandBar的使用
- SWT/Jface ControlDecoration 使用
- Swt/Jface treeViewer的使用
- Swt/Jface treeViewer的使用
- Swt/Jface treeViewer的使用
- Swt/Jface treeViewer的使用
- SWT/Jface TitleAreaDialog/TrayDialog 使用
- SWT/JFACE
- JFace/SWT
- SWT Jface
- SWT/Jface
- Eclipse Workbench之外使用SWT和JFace
- SWT(JFace)体验之ViewForm的使用
- SWT/Jface 监听器下Event的使用
- SWT/JFACE之TableViewer的使用
- swt/jface中FileDialog的使用
- 陕西引汉济渭工地宿舍火灾已致13死24伤-陕西-引汉济渭-火灾
- asp.net 练习jsonp
- Iphone开发基础篇(八)-ObjectC之Xcode快捷键
- TTL和CMOS电平总结(回答了什么是TTL和CMOS电平)
- PLSQL Developer V9.0.2.1621 注册码
- SWT/Jface ExpandBar使用
- 将一个项目导入到另一个项目里
- 如何修改MyEclipse的默认工作路径Workplace
- [转]: STL priority_queue 优先队列
- weblogic10出现ClassCastException: weblogic.xml.jaxp.RegistrySAXParserFactory cannot be cast
- Multitable INSERT 的用法
- c#面试题及答案(二)
- 创建文件默认名字和公司的修改
- 数据结构:堆