编辑行时JTable,更改ENTER动作?

问题描述 投票:1回答:1

我有JTable的问题。我需要编辑一些行,但是当我完成并按ENTER键时,我想要像在数据库中保存一样进行更改操作。这是我的代码:

// JTable PDV
    tablePDV = new JTable(pdvTableModel) {
        // Editable Enable || Disable
        public boolean isCellEditable(int rowIndex, int colIndex) {
            if (check == true) {
                if (rowIndex == rowSelectedIndex
                        && colIndex == colSelectedIndex) {
                    return super.isCellEditable(rowIndex, colIndex);
                }
            }
            return false;
        }
    };

    tablePDV.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseExited(MouseEvent arg0) {
            tablePDV.clearSelection();
            tablePDVSecond.clearSelection();
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            tableMousClick(tablePDV, e, 436, 455, 477, 498, 1);

        }
    });
java swing jtable action enter
1个回答
-1
投票

enter image description here

int key = evt.getKeyCode();

 if (key == KeyEvent.VK_ENTER) {

     //code here

 }

右键单击Jtable和事件,KeyReleased。

© www.soinside.com 2019 - 2024. All rights reserved.