I
I
Ilya2013-12-18 19:59:32
Java
Ilya, 2013-12-18 19:59:32

Why doesn't CellEditorListener work?

Hello! Actually the question I think is clear.

Listing
/**
     * Creates new form mainFrame
     */
    public mainFrame() {
        initComponents();
        initCellEditor();
    }
    
    /**
     * Инициализация обработчика редактирования ячейки
     */
    private void initCellEditor() {
        javax.swing.DefaultCellEditor editor = new javax.swing.DefaultCellEditor(new javax.swing.JTextField());
        editor.addCellEditorListener(new CellEditorListener() {
            @Override
            public void editingStopped(ChangeEvent e) {
                int indexCol = tableData.getSelectedColumn();
                int indexRow = tableData.getSelectedRow();
                double value = Double.parseDouble(tableData.getValueAt(indexRow, indexCol).toString());
                javax.swing.JOptionPane.showMessageDialog(rootPane, "Выбрана ячейка по значением: " + value);
            }

            @Override
            public void editingCanceled(ChangeEvent e) {
                // pass
            }
        });
        this.tableData.setCellEditor(editor);
    }


When editing a cell, the code doesn't even pass into the editingStopped method .

How else can you fasten the processing after editing the cell, except for the setValueAt overload , otherwise it seems to me not very good to climb into such functions, or what do you think?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Lopatin, 2013-12-18
@rpsv

And what prevents you from catching changes in the TableModel using the TableModelListener?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question