• Post Reply Bookmark Topic Watch Topic
  • New Topic

Editable Cell in JTable

 
Karthick Dharani Vidhya
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a JTable in application. One cell in my table in editable. That cell will take integer as value. Say if some one has entered '10' in that cell. If someone wants to change that 10 to 30 (or something else), once that user selects that cell and start typing 30 what is happening is 30 gets appending to the previously entered 10 and becomes 1030. Once if some one selects that paricular cell and starts entering new value it should override the existing value instead of just getting appended with it.

Any clue on this?

Thanks in advance for the same.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Karthick Dharani Vidhya:
.. what is happening is 30 gets appending to the previously entered 10 and becomes 1030. ..it should override the existing value instead of just getting appended with it.


One way of doing this is as follows:
I am presuming your editor is some kind of JTextComponent. If so, what you can do, is call JTextComponent#selectAll on focus gain. In that case, whatever the user types, will replace the selected text.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!