Link to home
Start Free TrialLog in
Avatar of lizzzard
lizzzardFlag for Netherlands

asked on

Cell listener on JTable

Hi,

I have a JTable and implemented a model. I implemented the setValueAt(...) method to reflect the user input in my model. However, the setValueAt(...) method is not reliable enough, because it only fires when the user actually LEAVES the cell. If he does some input and then hits a button, the model is still in the old state. How can I force each and every input the user makes to be reflected in my model? Do I have to add a listener that updates the model at user input? In that case, can you show me an example, cause Im a Swing noob :)

Thanks in advance!

Regards,
Lizzz
ASKER CERTIFIED SOLUTION
Avatar of Tomas Helgi Johannsson
Tomas Helgi Johannsson
Flag of Iceland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try
    jTable.getCellEditor().stopCellEditing();
Avatar of lizzzard

ASKER

I tried stopCellEditing, but that doesnt work. It doesnt fire when I click the a button right after editing the cell, but not leaving it. I used some leads presented by Thomas' link, and implemented an editor off that.

Many thanks for your suggestions