I want use a JSpinner to edit percentage values in my JTable. I wrote the following code:
The problem is when users hit enter. When they manually typed the "%" sign and hit enter twice it works. When they didn't enter the "%" sign it doesn't work. I tried a keylistener on both the editor and the spinner and also an inputMap, but none of these things seem to be noticing events.
I had the same problem when the user exited the cell, which I tried to fix in the stopCellEditing() by adding a "%" sign. This does work but only in the case where the user has entered less then 2 fraction digits (otherwise it doesn't follow the
pattern "0.00%").
How can I get around these problems? I really want the users to be able to commit when they hit enter.