Problem with JTable(plzzzzz help)

Dear friends,

I got a problem with JTable.I am using a JTable and giving an apportunity for the users to edit it and I want to update the values.But while updating I am not getting the updated value for the last selected cell. I am using getValueAt(row,column) method in actionPerformed method of an actionListener.I am getting the updated values for all cells if the user removes the selection before he clickes the button where actionListener is registered.But if there is a selection exists for any cell in the Jtable i am not getting the updated values for that particular cell.

Plzzzz Help..............

Thanks & Regards,

Sarath.

[669 byte] By [Sarath_Krisa] at [2007-11-27 8:49:02]
# 1
After you create the table you need to add:table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
camickra at 2007-7-12 20:57:25 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanks cami.............................Thaks a lot..........................Your suggetion worked.........................
Sarath_Krisa at 2007-7-12 20:57:25 > top of Java-index,Desktop,Core GUI APIs...
# 3

Dear frds, now i am facing a new issuw i am getting an eXception as shown as below:

java.lang.ArrayIndexOutOfBoundsException: 3 >= 0

at java.util.Vector.elementAt(Vector.java:431)

at javax.swing.table.DefaultTableModel.setValueAt(DefaultTableModel.java:633)

at javax.swing.JTable.setValueAt(JTable.java:1794)

at javax.swing.JTable.editingStopped(JTable.java:3167)

at javax.swing.AbstractCellEditor.fireEditingStopped(AbstractCellEditor.java:124)

at javax.swing.DefaultCellEditor$EditorDelegate.stopCellEditing(DefaultCellEditor.java:329)

at javax.swing.DefaultCellEditor.stopCellEditing(DefaultCellEditor.java:214)

at javax.swing.JTable$GenericEditor.stopCellEditing(JTable.java:3498)

at javax.swing.JTable$CellEditorRemover.propertyChange(JTable.java:3959)

at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:330)

at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:257)

at java.awt.KeyboardFocusManager.firePropertyChange(KeyboardFocusManager.java:1284)

at java.awt.KeyboardFocusManager.setGlobalPermanentFocusOwner(KeyboardFocusManager.java:602)

at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:435)

at java.awt.Component.dispatchEventImpl(Component.java:3506)

at java.awt.Container.dispatchEventImpl(Container.java:1627)

at java.awt.Component.dispatchEvent(Component.java:3477)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

[root@sarath Proj]#

Sarath_Krisa at 2007-7-12 20:57:25 > top of Java-index,Desktop,Core GUI APIs...
# 4

> java.lang.ArrayIndexOutOfBoundsException: 3 >= 0

Well you can't just use setValueAt(...) on an empty table. You are trying to update the cell in the 4th row of the table and the table contains 0 rows. You need to add the row (or columns) to the table first before you can update it.

camickra at 2007-7-12 20:57:25 > top of Java-index,Desktop,Core GUI APIs...