aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTable Editing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable Editing" Watch "JTable Editing" New topic
Author

JTable Editing

Gary Kirkham
Greenhorn

Joined: Nov 03, 2001
Posts: 3
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

Joined: Sep 28, 2000
Posts: 508
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
 
 
subject: JTable Editing