六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 81|回复: 0

SWT Table单选按钮实现

[复制链接]

升级  55.67%

111

主题

111

主题

111

主题

举人

Rank: 3Rank: 3

积分
367
 楼主| 发表于 2013-2-5 01:37:35 | 显示全部楼层 |阅读模式
table_short = new Table (composite_short, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);GridData gd_table = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);gd_table.heightHint = 104;gd_table.widthHint = 639;table_short.setLayoutData(gd_table);table_short.setLinesVisible(true);table_short.setHeaderVisible(true);table_short.setSize (100, 100);                TableColumn tableColumn = new TableColumn(table_short, SWT.NONE);        tableColumn.setWidth(20);        tableColumn.setText("");                TableColumn tableColumn_1 = new TableColumn(table_short, SWT.NONE);        tableColumn_1.setWidth(100);        tableColumn_1.setText("a");                TableColumn tableColumn_2 = new TableColumn(table_short, SWT.NONE);        tableColumn_2.setWidth(100);        tableColumn_2.setText("b");                TableColumn tableColumn_3 = new TableColumn(table_short, SWT.NONE);        tableColumn_3.setWidth(100);        tableColumn_3.setText("c");                TableColumn tableColumn_4 = new TableColumn(table_short, SWT.NONE);        tableColumn_4.setWidth(100);        tableColumn_4.setText("d");                TableColumn tableColumn_5 = new TableColumn(table_short, SWT.NONE);        tableColumn_5.setWidth(100);        tableColumn_5.setText("e");                TableColumn tableColumn_6 = new TableColumn(table_short, SWT.NONE);        tableColumn_6.setWidth(100);        tableColumn_6.setText("f");                table_short.addListener (SWT.Selection, new Listener () {            public void handleEvent (Event event) {                String string = event.detail == SWT.CHECK ? "Checked" : "Selected";                TableItem[] titem = table_short.getItems();                for(int i = 0; i < titem.length; i++){                if(!event.item.equals(titem[i])){                titem[i].setChecked(false);                }                }                System.out.println (event.item + " " + string);            }        });for (int i=0; i<5; i++) {            TableItem item = new TableItem (table_short, SWT.NONE);            item.setText (new String[]{"", "item1"+i,"item2"+i,"item3"+i,"item4"+i,"item5"+i,"item6"+i,});        }
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表