2011-11-14 10 views

答えて

2

できません。より一般的には、すべてのプラットフォームでサポートされているわけではないため、SWTのテーブルやツリーにウィジェットを挿入することはできません。あなたが代わりに行うことができますすることは

  1. は正常とクリックした状態で、ボタンの2枚のスクリーンショットを取るです。

  2. 通常のスクリーンショットを画像として表に入れます。

  3. TableItemのハンドルをクリックします。ここで

は、チェックボックスの例です:与えられたhttp://tom-eclipse-dev.blogspot.com/2007/01/tableviewers-and-nativelooking.html

12

答えはテーブルまたは外で、カスタムの図面を使用して独自のボタンを実装するための良い方法いいです。ただし、SWTコントロールはJFaceテーブルに置くことができます。

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); 
} 
関連する問題