Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Editable Cell in JTable  RSS feed

 
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.
 
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!