mte01
asked on
tableChanged event
In a JTable when the user enters data in a cell & leaves the cell (by pressing tab or something), the tableChanged event gets fired (if I have a TableModelListener added to the JTable), what if the user didn't leave the cell and pressed another button directly (for example a save button), then the data will not be saved in the JTable (and thus will not be retrieved in its getValueAt() function), so what can I do?
I was thinking of programmatically processing the TAB key by the following piece of code:
DefaultFocusManager fm = new DefaultFocusManager();
fm.processKeyEvent(jtablex ,KeyEvent. VK_TAB); //where jtablex is an object of class JTable
The problem with this code is that KeyEvent.VK_TAB is an integer not a KeyEvent object (and there is no overloaded function to take a component and a KeyEvent object)
I was thinking of programmatically processing the TAB key by the following piece of code:
DefaultFocusManager fm = new DefaultFocusManager();
fm.processKeyEvent(jtablex
The problem with this code is that KeyEvent.VK_TAB is an integer not a KeyEvent object (and there is no overloaded function to take a component and a KeyEvent object)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Amazing!! it did just the right thing.......although stopCellEditing is a boolean function (not a void) that I thought only returns whether the user has stopped editing or not. It seems that what it does is that it forces that editing of the JTable to get stopped programmatically, and thus the data that's edited gets saved.
Thank you very much...you really deserve it
Thank you very much...you really deserve it
8-)
ASKER
I also have a few questions for you CEHJ...(I don't know if I am allowed to ask them by the moderator or not....). How old are you? Where do you live? How do you benefit from such programming expertise (i.e. what do you do in life)? What is the range of the amount of money that you can earn per month from such expertise? (I am asking this question because I am working on becoming one in the near future)
Thanks in advance
Thanks in advance
ASKER