Java SWT表格:无法从使用TableEditor创建的表格中检索数据
从我创建的表中检索数据时遇到问题。它显示一个复选框、字符串(取自所有首先添加的_映射_对象)和值为0.0到1.0的下拉组合。在表中编辑所有值后,如何检索这些值,即布尔值、字符串值和组合值复选框 尝试了Java SWT表格:无法从使用TableEditor创建的表格中检索数据,java,swt,Java,Swt,从我创建的表中检索数据时遇到问题。它显示一个复选框、字符串(取自所有首先添加的_映射_对象)和值为0.0到1.0的下拉组合。在表中编辑所有值后,如何检索这些值,即布尔值、字符串值和组合值复选框 尝试了TableItem[]items=table.getItems()的一些变体,但我只返回空值 final Table table = new Table(sectionsInfo, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
TableItem[]items=table.getItems()
的一些变体,但我只返回空值
final Table table = new Table(sectionsInfo, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
table.setLinesVisible(true);
InfogridData = new GridData();
InfogridData.horizontalSpan = 4;
InfogridData.horizontalAlignment = GridData.BEGINNING;
InfogridData.horizontalAlignment = GridData.FILL;
InfogridData.grabExcessHorizontalSpace = true;
InfogridData.verticalAlignment = GridData.BEGINNING;
InfogridData.verticalAlignment = GridData.FILL;
InfogridData.grabExcessVerticalSpace= true;
TableColumn column = new TableColumn(table, SWT.NONE);
column.setWidth(500);
TableColumn column2 = new TableColumn(table, SWT.NONE);
column2.setWidth(50);
table.setLayoutData(InfogridData);
for (int i = 0; i < all_mapping_objects.size(); i++) {
new TableItem(table, SWT.NONE);
}
TableItem[] items = table.getItems();
for (int i = 0; i < items.length; i++) {
TableEditor editor = new TableEditor(table); //defines editor which controls objects put in
CCombo combo = new CCombo(table, SWT.NONE | SWT.READ_ONLY);
editor.grabHorizontal = true;
for (float me = 0; me <= 10; me++) {
combo.add("" + me/10);
}
combo.setText("1.0");
editor.setEditor(combo, items[i], 1); // sets the column
editor = new TableEditor(table);
Button button = new Button(table, SWT.CHECK);
button.setText(all_mapping_objects.get(i).getTextf()); // mapping objects written to the table
button.pack();
editor.minimumWidth = button.getSize().x;
editor.horizontalAlignment = SWT.LEFT;
editor.setEditor(button, items[i], 0); // sets the column
}
最终表格=新表格(sectionsInfo,SWT.BORDER | SWT.MULTI | SWT.H|U SCROLL | SWT.V|U SCROLL);
表.setLinesVisible(真);
InfogridData=新的GridData();
InfogridData.horizontalSpan=4;
InfogridData.horizontalAlignment=GridData.Beging;
InfogridData.horizontalAlignment=GridData.FILL;
InfogridData.grabExcessHorizontalSpace=true;
InfogridData.verticalAlignment=GridData.Beging;
InfogridData.verticalAlignment=GridData.FILL;
InfogridData.grabeExcessVerticalSpace=true;
TableColumn column=新的TableColumn(表,SWT.NONE);
列。设置宽度(500);
TableColumn column2=新的TableColumn(表,SWT.NONE);
列2.设置宽度(50);
表.setLayoutData(InfogridData);
对于(int i=0;i 对于(float me=0;me您应该使用按钮上的SelectionListener(SWT.CHECK)
,对于cmbo
,也应该使用类似的方法。我建议您开始使用TableViewer
而不是使用SWT表