SWT中comboViewer 控件使用
来源:互联网 发布:html显示xml数据 编辑:程序博客网 时间:2024/04/19 06:39
package com.test.swt;
import org.eclipse.swt.widgets.Display;
public class TestComboViewer {
protected Shell shell;
/**
* Launch the application.
* @param args
*/
public static void main(String[] args) {
try {
TestTree window = new TestTree();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window.
*/
public void open() {
Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
/**
* Create contents of the window.
*/
protected void createContents() {
shell = new Shell();
shell.setSize(645, 440);
shell.setText("下拉列表框的使用");
final ComboViewer comboViewer = new ComboViewer(shell, SWT.NONE);
final Combo combo = comboViewer.getCombo();
combo.add("张三", 0);
combo.add("张二", 1);
combo.add("张一", 2);
combo.add("张晓", 3);
combo.add("张飞", 4);
combo.add("张宇", 5);
//设置默认值
combo.select(0);
comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent org) {
//String index=
// int index=comboViewer.getCombo().getSelectionIndex();
// String num=comboViewer.getCombo().getText();
// MessageDialog.openInformation(shell, "信息", "选择了:"+index+":"+num);
int index=combo.getSelectionIndex();
String num=combo.getText();
MessageDialog.openInformation(shell, "信息", "选择了:"+index+":"+num);
}
});
combo.setBounds(156, 90, 130, 25);
}
}
import org.eclipse.swt.widgets.Display;
public class TestComboViewer {
protected Shell shell;
/**
* Launch the application.
* @param args
*/
public static void main(String[] args) {
try {
TestTree window = new TestTree();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window.
*/
public void open() {
Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
/**
* Create contents of the window.
*/
protected void createContents() {
shell = new Shell();
shell.setSize(645, 440);
shell.setText("下拉列表框的使用");
final ComboViewer comboViewer = new ComboViewer(shell, SWT.NONE);
final Combo combo = comboViewer.getCombo();
combo.add("张三", 0);
combo.add("张二", 1);
combo.add("张一", 2);
combo.add("张晓", 3);
combo.add("张飞", 4);
combo.add("张宇", 5);
//设置默认值
combo.select(0);
comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent org) {
//String index=
// int index=comboViewer.getCombo().getSelectionIndex();
// String num=comboViewer.getCombo().getText();
// MessageDialog.openInformation(shell, "信息", "选择了:"+index+":"+num);
int index=combo.getSelectionIndex();
String num=combo.getText();
MessageDialog.openInformation(shell, "信息", "选择了:"+index+":"+num);
}
});
combo.setBounds(156, 90, 130, 25);
}
}
- SWT中comboViewer 控件使用
- 在Eclipse Forms中使用swt控件
- SWT 中控件只读
- swt控件的使用
- 在SWT中使用AWT和Swing的控件
- SWT中在表格上添加 控件,TableEditor的使用
- 如何正确使用SWT控件
- SWT中ScrollComposite使用
- SWT中使用Swing
- SWT 中嵌入Word 控件应用
- SWT中TableViewer的使用:
- 在SWT中使用ChartDirector
- 在swt中使用table
- SWT中使用AWT组件
- Eclipse中如何使用SWT
- 在SWT中使用jfreechart
- swt table控件的使用(shell)
- SWT中使用线程后,要改变面板中某个控件的值,报 thread invalid access错误
- IE常见的CSS的BUG(二)
- 判断字符串为空方法性能对比实验
- 操作系统的进程管理
- 如何在CSDN博客上插入公式
- android4.2 蓝牙 bluetooth第4节:OPP文件传输
- SWT中comboViewer 控件使用
- 在网页中获取天气预报信息
- 喵星战争(九):游戏主菜单的实现
- Qt5.0.2 + MinGw4.7 编译出来的程序,在windows平台下的发布与打包程序
- 计算广告学--笔记(2)
- Frogger ZOJ 1942 POJ 2253
- TSO的功能键
- android 4.2蓝牙bluetooth 第5节:接打电话
- 几种搜索引擎算法研究(转)