SWT:StackLayout(堆栈式布局)
来源:互联网 发布:北大青鸟陈璇java视频 编辑:程序博客网 时间:2024/06/10 22:37
shell.setLayout(new GridLayout());
//创建放置文本框的面板
final Composite parent = new Composite(shell, SWT.NONE);
//设置面板的布局数据
parent.setLayoutData(new GridData(GridData.FILL_BOTH));
//创建堆栈式布局
final StackLayout layout = new StackLayout();
//将堆栈式布局应用于面板
parent.setLayout(layout);
//创建10个文本框
final Text[] textArray = new Text[10];
for (int i = 0; i < 10; i++)
{
textArray[i] = new Text(parent, SWT.MULTI);
textArray[i].setText("这是第 " + i + "个文本框");
}
//设置堆栈中当前显示的控件
layout.topControl = textArray[0];
Button b = new Button(shell, SWT.PUSH);
b.setText("显示下一个文本框");
//保存当前显示的文本框的索引值
final int[] index = new int[1];
//为按钮添加单击事件
b.addListener(SWT.Selection, new Listener(){
public void handleEvent(Event e)
{
//计算出下一个文本框的索引数
index[0] = (index[0] + 1) % 10;
//设置当前显示的控件
layout.topControl = textArray[index[0]];
//重新刷新布局
parent.layout();
}
});
shell.setSize(200, 150);
//创建放置文本框的面板
final Composite parent = new Composite(shell, SWT.NONE);
//设置面板的布局数据
parent.setLayoutData(new GridData(GridData.FILL_BOTH));
//创建堆栈式布局
final StackLayout layout = new StackLayout();
//将堆栈式布局应用于面板
parent.setLayout(layout);
//创建10个文本框
final Text[] textArray = new Text[10];
for (int i = 0; i < 10; i++)
{
textArray[i] = new Text(parent, SWT.MULTI);
textArray[i].setText("这是第 " + i + "个文本框");
}
//设置堆栈中当前显示的控件
layout.topControl = textArray[0];
Button b = new Button(shell, SWT.PUSH);
b.setText("显示下一个文本框");
//保存当前显示的文本框的索引值
final int[] index = new int[1];
//为按钮添加单击事件
b.addListener(SWT.Selection, new Listener(){
public void handleEvent(Event e)
{
//计算出下一个文本框的索引数
index[0] = (index[0] + 1) % 10;
//设置当前显示的控件
layout.topControl = textArray[index[0]];
//重新刷新布局
parent.layout();
}
});
shell.setSize(200, 150);
- SWT:StackLayout(堆栈式布局)
- SWT(JFace)体验之StackLayout布局
- StackLayout布局
- SWT堆栈式布局的简单使用
- 自定义层叠布局StackLayout
- stackLayout
- SWT:充满式布局
- SWT:网格式布局
- 用Swing制作叠加面板|SWT中的StackLayout实现
- SWT:FormLayout表格式布局
- SWT GridLayout网格式布局
- swt布局
- SWT布局
- 实战SWT布局
- SWT中的布局类
- 理解SWT布局
- 理解SWT布局[1]
- SWT综合布局示例
- 常用Hash算法(C语言实现)
- 闭散列表及其查找算法的实现
- c int 转string 和string 转int
- 公有继承(public)、私有继承(private)、保护继承(protected)是常用的三种继承方式。
- 老工程改造为MAVEN工程(简单改造)
- SWT:StackLayout(堆栈式布局)
- python资 源
- JS总结:
- Bubble(9)
- 用curl 实现远程数据提交,支持文件上传 .
- C++转向Objective-C需要注意的地方(基础)。
- HDU1405:The Last Practice
- 打电话 三种方式 -要求真机测试
- 01背包问题