如何将 SWT 按钮控件插入到 JFace TableViewer 中?
最佳答案
给出的答案是在表格内外使用自定义绘图实现您自己的按钮的好方法。但是,您可以将 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);
}
关于swt - 向 JFace 表中插入一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8121278/