JTable with a complex editor

前端 未结 4 1987
花落未央
花落未央 2021-02-02 03:33

I have many custom editors for a JTable and it\'s an understatement to say that the usability, particularly in regard to editing with the keyboard, is lacking.

The main

4条回答
  •  南旧
    南旧 (楼主)
    2021-02-02 03:46

    I think that I solved it.
    To tell you the truth, I don't know what solved the problem, since I'm using a custom editor, a custom renderer and stuff...

    When a cell is highlighted and I press "abc", the 3 letters go on screen (cell, in this case).

    grid.addKeyListener(new KeyAdapter() {
        public void keyTyped(KeyEvent ke) {
            int l = grid.getSelectedRow();
            int c = grid.getSelectedColumn();
            grid.editCellAt(l, c);
        }
    });
    

    Well... I tried... =)
    (I don't know if it's the same because my JTable uses JTextField and JComboBox as editors).

提交回复
热议问题