简体   繁体   English

JTable不会失去对ENTER和TAB的关注

[英]JTable not losing focus on ENTER and TAB

table.changeSelection(table.getRowCount()-1, 3, false, false);

after setting the cell selection like above, the cell is selected and if i enter the value in to the cell, the cell goes to editing mode. 在如上设置单元格选择之后,选择单元格,如果我输入单元格中的值,则单元格进入编辑模式。 But, after the value is entered, if i press ENTER or TAB key the cell is still in editing mode. 但是,输入值后,如果按ENTER或TAB键,单元格仍处于编辑模式。 If i press some where on other component then only the cell closes editor mode. 如果我按下其他组件上的某个位置,则只有单元格关闭编辑器模式。

how to solve this? 怎么解决这个?

after setting the cell selection like above, the cell is selected and if i enter the value in to the cell, the cell goes to editing mode 在如上设置单元格选择之后,选择单元格,如果我输入单元格中的值,则单元格进入编辑模式

  1. for better help sooner post an SSCCE demonstraded your issue about table.changeSelection and TableCellEditor 为了更好的帮助, SSCCE发布了关于table.changeSelectionTableCellEditor

  2. have to override stopCellEditing 必须覆盖stopCellEditing

depends of your TableCellEditor 取决于你的TableCellEditor

table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

or 要么

@Override
public boolean stopCellEditing() {// @see CellEditor#stopCellEditing()
    fireEditingStopped();
    return true;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM