如何在不使用鼠标监听器的情况下编辑SWT表值?可编辑的SWT表
Q
可编辑的SWT表
3
A
回答
7
在下面的链接帮助中做了TableEditor
片段吗?
在TableEditor
部分的第一个示例使用上表中的SelectionListener
(不像使用你提到你不想MouseDown事件的第二个例子)
也许你可以利用TraverseListener
或KeyListener
也可以帮助你实现你想要的。
4
final int EDITABLECOLUMN = 1;
tblProvisionInfo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Clean up any previous editor control
final TableEditor editor = new TableEditor(tblProvisionInfo);
// The editor must have the same size as the cell and must
// not be any smaller than 50 pixels.
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.minimumWidth = 50;
Control oldEditor = editor.getEditor();
if (oldEditor != null)
oldEditor.dispose();
// Identify the selected row
TableItem item = (TableItem) e.item;
if (item == null)
return;
// The control that will be the editor must be a child of the
// Table
Text newEditor = new Text(tblProvisionInfo, SWT.NONE);
newEditor.setText(item.getText(EDITABLECOLUMN));
newEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent me) {
Text text = (Text) editor.getEditor();
editor.getItem()
.setText(EDITABLECOLUMN, text.getText());
}
});
newEditor.selectAll();
newEditor.setFocus();
editor.setEditor(newEditor, item, EDITABLECOLUMN);
}
});
这里tblProvision
是你的表的名字。你现在可以点击它来编辑你的表格。我已申报EDITABLECOLUMN
。这是你想编辑的column
。
1
如果你可以使用的JFace以及不只是疼痛SWT,看看在JFace Snippets,尤其是
- Snippet036FocusBorderCellHighlighter - 通过重点边框显示一次凸显了当前选定单元格演示键盘导航新的小区导航支持
- Snippet034CellEditorPerRowNewAPI的更多的灵活性 - 在一列展示不同CellEditor中-类型与JFace的观看者的3.3-API
0
您可以获取或设置项的值,例如:
Table table = new Table(parent, SWT.NONE);
TableItem item = new TableItem(table, SWT.NONE);
item.setText("My new Text");
0
我建议你给我们TableViewer,它是它,你可以使用数据绑定很容易得非常强大的表格。
相关问题
- 1. SWT ComboBoxCellEditor可编辑
- 2. SWT表格无法编辑
- 3. SWT可编辑组合 - 高亮文本
- 4. 使用编辑器调整SWT表格
- 5. Java SWT WYSIWYG HTML编辑器
- 6. jQuery可编辑/不可编辑表格
- 7. AngularJS可编辑表
- 8. 如何制作SWT树的特定级别可编辑
- 9. angularjs的可编辑表格
- 10. MVC中的可编辑表
- 11. 添加无编辑新行SWT/JFace的表
- 12. 如何在Eclipse RCP中编辑SWT表格的单元格?
- 13. SWT源代码编辑器小工具
- 14. 如何在SWT中编辑树节点
- 15. 使用SWT eclipse在Java中编辑GridData?
- 16. primefaces:可编辑数据表中的不可编辑列
- 17. 用Javascript编写的可编辑表格
- 18. Yesod可编辑表格
- 19. jQuery可编辑数据表
- 20. 用户可编辑表
- 21. KnockoutJS可编辑表脚
- 22. 可编辑列表查看
- 23. 使用Mindmup可编辑表格使某些列不可编辑
- 24. WPF可编辑列表视图与可编辑组合框
- 25. 使用另一个编辑器上的按钮打开编辑器RCP,SWT,JAVA
- 26. 用作表编辑器的SWT DateTime控件不会延伸到表格底部
- 27. 如何使用Javascript或Java编辑可编辑的pdf表单
- 28. 可编辑的HTML表格单元格编辑
- 29. jQuery可编辑/可排序列表
- 30. UWP中可编辑的MIDI编辑器
在这种情况下,只有一列可以编辑。它是否正确? – Zoot 2013-09-30 21:11:26