Selecting values in the JTable cell while editing
Hi
While I try to edit any value in table cell, editor positions the cursor at the end of the value but I want it select the whole value so that if the user want to enter new value, separate action for deletion of existing value is not required. Suppose, there is a value 245.05 is a specific cell of my table. What ever I write in this cell while editing (without manual selection) it should override the existing value of 245.05.
I searched the web but could not figure out the appropriate solutions.
Can anyone help?
Regards,
Mortoza
[573 byte] By [
mortozaa] at [2007-11-26 16:24:21]

# 4
I'm not the author of the original piece, but you should be able to figure out how to do something similar in your code.If you still have difficulty, then post specific questions here. "It doesn't work" isn't really a question.
# 7
Hi camickr
Thanks for the suggestion. I checked your code from the link. I have ran your code and found
1) the 1st key in of text/number is vanished, only 2nd key in texts displayed. e.g. if I type 700 on this cell, only 00 is remained visible.
2) How do I validate data type i.e. numeric, date etc.?
Thanks in advance for the help.
Mortoza
# 8
> 1) the 1st key in of text/number is vanished, only 2nd key in texts displayed
Works fine for me using JDK1.4.2 on XP
> 2) How do I validate data type i.e. numeric, date etc.?
Override the getColumnClass method to return the appropriate class type and the appropriate editor will be used.