我正在创建一个表格,我想用4个列中的组合框输入每个单元格,这是我的代码:
protected void createContents() {
shell = new Shell();
table = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION);
TableColumn tblclmnCallers = new TableColumn(table, SWT.NONE);
tblclmnCallers.setWidth(100);
tblclmnCallers.setText("Callers");
TableColumn tblclmnCallersExecuted = new TableColumn(table, SWT.NONE);
tblclmnCallersExecuted.setWidth(150);
tblclmnCallersExecuted.setText("CallersExecuted");
TableColumn tblclmnCallees = new TableColumn(table, SWT.NONE);
tblclmnCallees.setWidth(100);
tblclmnCallees.setText("Callees");
TableColumn tblclmnCalleesExecuted = new TableColumn(table, SWT.NONE);
tblclmnCalleesExecuted.setWidth(150);
tblclmnCalleesExecuted.setText("CalleesExecuted");
int i = 0;
for (MethodTrace2 meth : methodtraces2) {
TableItem item1 = new TableItem(table, SWT.NONE);
List<Method2Representation> callees = meth.getCalleesList();
List<Method2Representation> callers = meth.getCallersList();
List<Method2Representation> callersExecuted = meth.getCallersListExecuted();
List<Method2Representation> calleesExecuted = meth.getCalleesListExecuted();
TableEditor tableEditor = new TableEditor(table);
if (i < 100) {
TableItem[] items = table.getItems();
items = table.getItems();
CCombo comboCallers = new CCombo(table, SWT.NONE);
comboCallers.setText("Callers");
for (Method2Representation caller : methodtraces2.get(i).getCallersList()) {
comboCallers.add(caller.toString());
}
// items = table.getItems();
CCombo comboCallees = new CCombo(table, SWT.NONE);
comboCallees.setText("Callees");
for (Method2Representation callee : methodtraces2.get(i).getCalleesList()) {
comboCallees.add(callee.toString());
}
items = table.getItems();
CCombo comboCallersExecuted = new CCombo(table, SWT.NONE);
comboCallersExecuted.setText("CallersExecuted");
for (Method2Representation callerExecuted : methodtraces2.get(i).getCallersListExecuted()) {
comboCallersExecuted.add(callerExecuted.toString());
}
items = table.getItems();
CCombo comboCalleesExecuted = new CCombo(table, SWT.NONE);
comboCalleesExecuted.setText("CalleesExecuted");
for (Method2Representation calleeExecuted : methodtraces2.get(i).getCalleesListExecuted()) {
comboCalleesExecuted.add(calleeExecuted.toString());
}
tableEditor.setEditor(comboCallers, item1, 10);
tableEditor.setEditor(comboCallees, item1, 11);
tableEditor.setEditor(comboCallersExecuted, item1, 12);
tableEditor.setEditor(comboCalleesExecuted, item1, 13);
tableEditor.grabHorizontal = true;
i++;
}
}
}
只有第13列“CalleesExecuted”获得带有相应组合框的输入,第10,11和12列完全留空,即使我也编写了用于输入它们的代码,我不知道什么是错的以及它们为什么不输入< / p>