• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need double click to edit in JTable not single click

 
Brian Snyder
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I override the TableCellEditor correctly to allow a cell to be editable on a double click rather than a single click? I have no problem changing the font, color, background and such be using a JTextField as the returning component. How do I make a double click activate editing?
Many thanks in advance.
[ April 25, 2002: Message edited by: Brian Snyder 2002 ]
 
Brian Snyder
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone there with an answer??
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Snyder 2002 is not a valid user name. Please re-read the JavaRanch UserName Guidelines and re-register with a valid user name. ( "Brian Snyder" would be a valid username... just take the "2002" off the end. )

The only way I can think that you could change when editing gets launched is to replace the ListSelectionModel with one of your own ( via setSelectionModel() in JTable ) and set selected row and selected column on a single click, but do not set editing row and editing column. Then change the DefaultCellRenderer to have a mouse listener that sets the editing row and editing column of the table when it is double clicked.

-Nate
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the javadocs of javax.swing.DefaultCellEditor
This class has a method setClickCountToStart().
Hope this helps
 
Brian Snyder
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually figured it out a different way. Get the click count and use the editCellAt(selRow, selCol);
It worked like a charm!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!