-1

I want to take value from cell of JTable while editing it continuously.So can i apply KeyReleased Event to cell and how?

user2042166
  • 121
  • 1
  • 1
  • 6
  • still (same as your earlier questions) sounds like you are doing something basically wrong - and still (again same as your earlier questions) no SSCCE? What exactly are you trying to achieve and why? What exactly is going wrong when you tried? You did read the appropriate chapters of the tutorial referenced in the swing tag wiki, didn't you? – kleopatra Jul 16 '13 at 08:33
  • klepatra Sir,i want to say can i get value from JTable while editing it just like when get the values from textfield when keyreleased event occur and Now remove the Negative Mark. – user2042166 Jul 19 '13 at 09:40

2 Answers2

1

Don't use a KeyListener.

Instead you can get the default editor for the column which will use a JTextField as the editor. Then you add a DocumentListener to the text field. A DocumentEvent will be generated every time you add/remove text.

camickr
  • 321,443
  • 19
  • 166
  • 288
0
 public void KeyReleased(MouseEvent e)
      {

         JTable target = (JTable)e.getSource();
         int row = target.getSelectedRow();
         int col = target.getSelectedColumn();

        Object data = (Object)table.getValueAt(row, col);
        JOptionPane.showMessageDialog(null, data);

          }
Ganesh Rengarajan
  • 2,006
  • 13
  • 26