Start editing in a cell in JTable on gaining focus

后端 未结 2 587
执笔经年
执笔经年 2021-01-15 06:39

I have defined cell editors for the two columns in my table in the following manner:

Java Code:

JComboBox combo = new JComboBox();
//code to add item         


        
2条回答
  •  执念已碎
    2021-01-15 06:59

    1. This example overrides editCellAt() in a JTable having a DefaultCellEditor using JTextField.

    2. You can bind the Space key to the startEditing action defined for JTable:

      table.getInputMap().put(
          KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "startEditing");
      

提交回复
热议问题