详细些的使用用例代码。
现在要用到了SWT中的Table组件,但以前没用过,这里又没有文档。具体用法是:当一个下拉列表被选中后触发根据下拉列表中的值查询某表中的数据,显示在Table中,最好也能加上修改添加的代码
现在要用到了SWT中的Table组件,但以前没用过,这里又没有文档。具体用法是:当一个下拉列表被选中后触发根据下拉列表中的值查询某表中的数据,显示在Table中,最好也能加上修改添加的代码
解决方案 »
- java.net.proxy存在线程安全问题吗?
- 急问 缺少返回语句 在线等
- 为什么,为什么,一个小小的问题困扰了我一天,麻烦前辈帮帮我,我不想说跪求,因为我是男人,所以不会轻易下跪
- 我在用递归方法实现阶乘,运行时会报错 StackOverFlowError
- 刚刚学,请教大家
- 请教用JBuilder中的Database Pilot工具连接Sybase数据问题!!!
- 新手请教,我如何实现此多线程模型?(up有分)
- 一个关于vj6上运行白板程序的问题!
- 通过bat运行Application如何去掉DOS窗口?
- 我要学java,有了JDK,是不是还需要一个集成开发环境,如Jbuilder???
- 测试CardLayout出现的异常
- 见鬼了, Java变量赋值的奇怪现象
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;public class TableDemo { public static Display myDisplay;
public static boolean internalCall = false; public static void main(String[] args) {
internalCall = true;
myDisplay = new Display();
TableDemo td = new TableDemo();
td.runDemo(myDisplay);
} public void runDemo(Display display) {
myDisplay = display;
Shell shell = new Shell(display);
shell.setSize(300,300);
shell.setText("Table Demo"); Table table1 = new Table(shell, SWT.BORDER);
table1.setBounds(10,10,270,60);
table1.setLinesVisible(true); TableColumn name = new TableColumn(table1,SWT.LEFT);
name.setText("Name");
name.setWidth(50);
TableColumn age = new TableColumn(table1,SWT.RIGHT);
age.setText("Age");
age.setWidth(30);
TableColumn address = new TableColumn(table1,SWT.LEFT);
address.setText("Address");
address.setWidth(200); TableItem item1 = new TableItem(table1,SWT.NONE);
item1.setText(new String[] {"Sarah","15","390 Sussex Ave"});
TableItem item2 = new TableItem(table1,SWT.NONE);
item2.setText(new String[] {"Joseph","56","7 Yourstreet St"}); Table table2 = new Table(shell, SWT.CHECK|SWT.HIDE_SELECTION);
table2.setBounds(10,80,270,80);
table2.setHeaderVisible(true); TableColumn fruit = new TableColumn(table2,SWT.LEFT);
fruit.setText("Fruit");
fruit.setWidth(100);
TableColumn colour = new TableColumn(table2,SWT.LEFT);
colour.setText("Colour");
colour.setWidth(170); TableItem fruit1 = new TableItem(table2,SWT.NONE);
fruit1.setText(0,"Apple");
fruit1.setText(1,"Red");
fruit1.setChecked(true);
TableItem fruit2 = new TableItem(table2,SWT.NONE);
fruit2.setText(new String[] {"Kiwi","Green"});
fruit2.setBackground(new Color(display,255,0,0));
TableItem fruit3 = new TableItem(table2,SWT.NONE);
fruit3.setText(new String[] {"Banana","Yellow"}); Table table3 = new Table(shell, SWT.FULL_SELECTION);
table3.setLinesVisible(true);
table3.setBounds(10,180,270,80); TableColumn first = new TableColumn(table3,SWT.LEFT);
first.setResizable(true);
first.setText("First");
first.setWidth(80);
TableColumn second = new TableColumn(table3,SWT.CENTER);
second.setText("Second");
second.setWidth(80);
TableColumn third = new TableColumn(table3,SWT.RIGHT);
third.setText("Third");
third.setWidth(80); String[] numbers = new String[] {"One","Two","Three"};
TableItem firstItem = new TableItem(table3,SWT.NONE);
firstItem.setText(numbers);
TableItem secondItem = new TableItem(table3,SWT.NONE);
secondItem.setText(numbers);
TableItem thirdItem = new TableItem(table3,SWT.NONE);
thirdItem.setText(numbers);
TableItem fourthItem = new TableItem(table3,SWT.NONE);
fourthItem.setText(numbers); table3.select(1); shell.open(); while(!shell.isDisposed()){
if(!display.readAndDispatch())
display.sleep();
}
if (internalCall) display.dispose();
}
}
有时间好好学学SWT,还请指教啊。