• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTable Editing

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JTable that allows the user to enter data. The user clicks on a cell and starts typing to enter data. This works fine. The problem is when the user later clicks on a cell that already has data and begins to type. The behavior I would like is for the entire text in the selected cell's editor to be highlighted (selelected) for replacement. If the user wants to replace a portion of the text or append text he would click again and unhighlight the text. Right now when the user clicks a cell the text from the cell is placed in the editor and the characters the user types are appended to the end of the cells current contents. Can anyone help me with my problem?
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
you can write your one TableCellEditor. that would be a class like:
private TableCellEditor extends JTextField
{
// what comes in here is explained in the swing tutorial at
// sun's. (that's where you specify that you want the text
// highlighted.)
// it's just one method and you return an instance of "this"
}
chantal
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic