更新时间:2022-03-25 19:58:20
DefaultCellEditor
对于许多 JTable
单元格类型委托给 JTextField
,它将 Delete 键绑定到 delete-next
行动。要抢占默认行为,您必须从 DefaultCellEditor
中删除现有绑定,如 如何使用键绑定:如何制作和删除键绑定 。您可以使用自己的绑定替换它,如示例所示; 此处显示典型的 DefaultCellEditor
。
The DefaultCellEditor
for many JTable
cell types delegates to a JTextField
, which binds the Delete key to the delete-next
action. To preempt the default behavior, you'll have to remove the existing binding from DefaultCellEditor
, as shown in How to Use Key Bindings: How to Make and Remove Key Bindings. You can replace it with your own binding, as shown in this example; a typical DefaultCellEditor
is shown here.