2011-11-14 76 views

回答

12

給出的答案是很好用圖紙定做,或在表外,​​以實現自己的按鈕,一個很好的方式。但是,您可以將SWT控件放入JFace Tables中。

http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/PlacearbitrarycontrolsinaSWTtable.htm

用於構建表與含有組合框,文本框,並且通過鏈路提供的按鈕列的解決方案是:

Table table = new Table(shell, SWT.BORDER | SWT.MULTI); 
table.setLinesVisible(true); 
for (int i = 0; i < 3; i++) { 
    TableColumn column = new TableColumn(table, SWT.NONE); 
    column.setWidth(100); 
} 
for (int i = 0; i < 12; i++) { 
    new TableItem(table, SWT.NONE); 
} 
TableItem[] items = table.getItems(); 
for (int i = 0; i < items.length; i++) { 
    TableEditor editor = new TableEditor(table); 
    CCombo combo = new CCombo(table, SWT.NONE); 
    editor.grabHorizontal = true; 
    editor.setEditor(combo, items[i], 0); 
    editor = new TableEditor(table); 
    Text text = new Text(table, SWT.NONE); 
    editor.grabHorizontal = true; 
    editor.setEditor(text, items[i], 1); 
    editor = new TableEditor(table); 
    Button button = new Button(table, SWT.CHECK); 
    button.pack(); 
    editor.minimumWidth = button.getSize().x; 
    editor.horizontalAlignment = SWT.LEFT; 
    editor.setEditor(button, items[i], 2); 
} 
相關問題