简体   繁体   中英

JTable when edit row, change ENTER action?

I have problem with JTable. I need to edit some row, but when i finish and press ENTER, i want change action like save in Database. This is my code:

// 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);

        }
    });

在此处输入图片说明

int key = evt.getKeyCode();

 if (key == KeyEvent.VK_ENTER) {

     //code here

 }

right click to Jtable and event ,KeyReleased.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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