How to get the text content on the swt table with arbitrary controls
- by amarnath vishwakarma
I have different controls placed on a table using TableEditor.
...
TableItem [] items = table.getItems ();
for (int i=0; i<items.length; i++) {
TableEditor editor = new TableEditor (table);
final Text text1 = new Text (table, SWT.NONE);
text1.setText(listSimOnlyComponents.get(i).getName());
text1.setEditable(false);
editor.grabHorizontal = true;
editor.setEditor(text1, items[i], 0);
editor = new TableEditor (table);
final CCombo combo1 = new CCombo (table, SWT.NONE);
combo1.setText("");
Set<String> comps = mapComponentToPort.keySet();
for(String comp:comps)
combo1.add(comp);
editor.grabHorizontal = true;
editor.setEditor(combo1, items[i], 1);
} //end of for
...
When I try to get the text on the table using getItem(i).getText, I get empty string
...
TableItem [] items = table.getItems ();
for(int i=0; i<items.length; i++) {
TableItem item = items[i];
String col0text = items[i].getText(0); //this text is empty
String col1text = items[i].getText(1); //this text is empty
}
...
Why does getText returns empty strings even when I have text appearing on the table?