社区
Eclipse
帖子详情
eclipse 下关于Table删除行问题!急
w563847254
2010-08-13 12:01:48
我在table中添加了一些Text、Button、Combo组件,删除的时候都释放掉了,能够实现删除一行,现在的问题是我删除了之后要用鼠标点下下面的行才能填补上来,请问这是什么情况?怎么解决?急急急!
...全文
339
6
打赏
收藏
eclipse 下关于Table删除行问题!急
我在table中添加了一些Text、Button、Combo组件,删除的时候都释放掉了,能够实现删除一行,现在的问题是我删除了之后要用鼠标点下下面的行才能填补上来,请问这是什么情况?怎么解决?急急急!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
忘了隐藏
2010-08-13
打赏
举报
回复
删除的时候刷新下表试试呢
kanwy
2010-08-13
打赏
举报
回复
建议使用tableviewer,可以删除的。
不用重新查询、重新加载数据。
可以把table里面显示的数据对象都取出来,从删除占位起,后面的前移,然后刷新。一年前有接触过一模一样的功能开发。呵呵
w563847254
2010-08-13
打赏
举报
回复
[Quote=引用 3 楼 martin_jay 的回复:]
删除后,重新调用获取列表的方法。使得后台重新查询数据,前台重新加载数据。
[/Quote]
上面是我的代码,麻烦帮我看看具体怎么操作,谢谢!
w563847254
2010-08-13
打赏
举报
回复
public void createTable(Group group){
final ScrolledComposite scrolledComposite=new ScrolledComposite(group ,SWT.BORDER
| SWT.H_SCROLL | SWT.V_SCROLL);
scrolledComposite.setBounds(10, 30, 850, 500);
final Composite composite = new Composite(scrolledComposite, SWT.NONE);
composite.setBounds(0, 0, 820, 450);
table = new Table(composite,SWT.FULL_SELECTION | SWT.BORDER);
table.setBounds(0, 0, 750, 300);
table.setLinesVisible(true);
table.setHeaderVisible(true);
//table.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
table.addListener(SWT.MeasureItem, new Listener(){
public void handleEvent(Event event) {
event.width = table.getGridLineWidth();
event.height = (int)Math.floor(event.gc.getFontMetrics().getHeight()*1.5);
}
});
final Hashtable<Long,Vector> hashtable= new Hashtable<Long,Vector>();
String columnName[] = {"","通道ID","标号","斜率","截距","数字输入数","小数点",
"有效数字位","单位","数据通道类型","输入种类","高位报警","低位报警",
"警报号","最高有效数据","最低有效数据","有效百分比","描述","记录报告1",
"记录报告2","记录报告3","记录报告4","串口输出","备用文件输出"};
TableColumn column[] = new TableColumn[24];
for(int i=0;i<24;i++){
column[i] = new TableColumn(table,SWT.NONE);
column[i].setWidth(90);
column[i].setText(columnName[i]);
}
column[0].setWidth(30);
final Button button1 = new Button(composite,SWT.FLAT),
button2 = new Button(composite,SWT.FLAT);
button1.setBounds(10, 310, 100, 25);
button2.setBounds(500,310,100,25);
button1.setText("添加通道");
button2.setText("删除通道");
button1.addSelectionListener(new SelectionAdapter(){
int i = 1;
public void widgetSelected(SelectionEvent e){
Vector<TableEditor> editors = new Vector<TableEditor>();
TableItem tab = new TableItem(table,SWT.NONE);
tab.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
long tableRowNum = tab.hashCode();
TableEditor editor[] = new TableEditor[23];
for(int j=0;j<23;j++){
editor[j] = new TableEditor(table);
editor[j].grabHorizontal = true;
editors.add(editor[j]);
}
hashtable.put(tableRowNum, editors);
Text text[] = new Text[14];
String[] textStr1={""+i,"C"+i,"1","0","1","2","5"
,"0","0","0","0","0","75",""};
for(int j=0;j<text.length;j++){
text[j] = new Text(table,SWT.NONE);
text[j].setText(textStr1[j]);
}
for(int j=0;j<7;j++){
editor[j].setEditor(text[j], tab, j+1);
}
CCombo combo[] = new CCombo[3];
for(int j=0;j<3;j++){
combo[j] = new CCombo(table,SWT.READ_ONLY | SWT.SIMPLE);
}
String str1[]={"ppm","pphm","ppb","mg/m3","ug/m3","C","F","deg","mbar",
"m/s","kph","mph","%","mgHg","Mm-1","W/m"};
String str2[]={"Voltage","Frequency","Counter","NO","NOX","NO2",
"Concentration","Deviation","Light Level","Logger","CH4","NMHC",
"THC","H2S","TRS","O3","CO","NH3","SO2","Nx","WS","WD"};
String str3[]={"Average","Total","Std Dev","Max","Min","Max Time","Min Time"};
combo[0].setItems(str1);
combo[1].setItems(str2);
combo[2].setItems(str3);
for(int j=0;j<3;j++){
combo[j].select(0);
editor[7+j].setEditor(combo[j],tab,7+j+1);
}
for(int j=0;j<7;j++){
editor[10+j].setEditor(text[7+j], tab, 10+j+1);
}
Button checkBut[] = new Button[6];
for(int j=0;j<6;j++){
checkBut[j] = new Button(table,SWT.CHECK | SWT.CENTER);
checkBut[j].setSelection(true);
checkBut[j].pack();
editor[17+j].setEditor(checkBut[j], tab, 17+j+1);
}
i++;
tableRowNum++;
}
});
button2.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
int row = table.getSelectionIndex();
if(row == -1)
return;
table.remove(row);
long rowNum = table.getItem(row).hashCode();
//table.getItem(row).dispose();
Iterator<Long> iterator = hashtable.keySet().iterator();
if(iterator!=null){
while(iterator.hasNext()){
Long key = iterator.next();
if(key==null){
return;
}
if(key == rowNum){
Vector editors = (Vector)hashtable.get(key);
Iterator eiter = editors.iterator();
while(eiter.hasNext()){
TableEditor editor = (TableEditor) eiter.next();
editor.getEditor().dispose();
editor.dispose();
}
hashtable.remove(key);
//table.getItem(row).dispose();
table.redraw();
table.update();
break;
}
}
}
}
});
}
Martin_Jay
2010-08-13
打赏
举报
回复
删除后,重新调用获取列表的方法。使得后台重新查询数据,前台重新加载数据。
w563847254
2010-08-13
打赏
举报
回复
redraw(),update()都试过了!
eclipse
下载与安装
本套课程,详细讲了解
eclipse
的下载方法。如
eclipse
的下载位置、
eclipse
的历史版本选择、
eclipse
的应用环境选择、
eclipse
的平台选择等。同时简单介绍了
eclipse
的安装方法,以及如何创建项目
Java之基于
Eclipse
搭建SSH框架(下)
在上篇博客里,我简介了Tomcat滴配置与Struts2滴搭建,假设对这个还不会滴童鞋去看一下我滴上篇博客《Java之基于
Eclipse
搭建SSH框架(上)》。今天我们接着上篇博客滴内容。继续搭建我们滴SSH框架。 (一)在上篇博客滴...
mybatis入门
前言:作为一个使用eclispe多年的人来说,确实对
eclipse
都有点感情了,但是没办法,技术在发展,时代在进步,所以我今天准备彻底从抛弃
eclipse
转向idea了,再见
eclipse
!!! 一:在idea关联maven 注:想要pom.xml...
利用maven/
eclipse
搭建ssm(spring+spring mvc+mybatis)
本文旨在利用maven搭建ssm环境,而关于maven的具体内容,大家可以去阅读《Maven 实战》。其实园内这方面文章已有不少,那么为什么我还要重复造轮子呢?我只是想记录自己的实践过程罢了,附带着给别人以参考。对于...
hadoop完全分布式集群+Win
Eclipse
+Hbase+Hive+Zookeeper+Sqoop+SPARK试验机平台
三台Centos6.5虚拟机,模拟3个物理节点的Hadoop平台。并配置
Eclipse
连接
Eclipse
58,454
社区成员
49,450
社区内容
发帖
与我相关
我的任务
Eclipse
Java Eclipse
复制链接
扫一扫
分享
社区描述
Java Eclipse
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章