import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.*;
public class ZeileAuswaehlen {
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
Table table = new Table(shell,SWT.MULTI);
TableColumn column = new TableColumn(table,SWT.NONE);
column.setWidth(100);
column.setText("12");
TableColumn column2 = new TableColumn(table,SWT.NONE);
column2.setWidth(100);
column2.setText("12");
for(int i=0; i<20;i++){
TableItem ti = new TableItem(table,SWT.NONE);
if(i==5 || i==3 || i==12){
Button check = new Button(table,SWT.CHECK);
check.setData(i);
check.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
Button thisButton= (Button) e.widget;
int zeilennummer=(Integer)thisButton.getData();
if(thisButton.getSelection()){
System.out.println("Zeile Nummer"+zeilennummer+"wurde ausgewählt");
}
}
});
TableEditor tbl_editor = new TableEditor(table);
tbl_editor.grabHorizontal=true;
tbl_editor.minimumHeight=check.getSize().x;
tbl_editor.minimumWidth=check.getSize().y;
tbl_editor.setEditor(check,ti,0);
}
ti.setText(1,"Hallo");
}
shell.setSize (200, 200);
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}