• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable Editing

 
Gary Kirkham
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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?
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic