• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable: highlight text of cell

 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to highlight text of the cell when a user clicks inside it. I think I have to use CellEditor to make cells JTextField, and then use selectAll() to select the text inside the cell. But, have trouble implementing it. I have a function that should make all cells JTextField:
public void setUpTextColumn(TableColumn textColumn) {
JTextField text = new JTextField();
textColumn.setCellEditor(new DefaultCellEditor(text));
}
but how do I set up listeners so text is highlighted when someone clicks inside it?
thanks,
Alex
 
Alex Draper
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a couple of methods in the API that are used to select a cell only.
the JTable has a method called
myJTable.setCellSelectionEnabled(true);

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!