How to get the text content on the swt table with arbitrary controls
        Posted  
        
            by amarnath vishwakarma
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by amarnath vishwakarma
        
        
        
        Published on 2009-03-11T14:51:58Z
        Indexed on 
            2010/04/07
            5:03 UTC
        
        
        Read the original article
        Hit count: 274
        
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?
© Stack Overflow or respective owner