• 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

Need double click to edit in JTable not single click

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone there with an answer??
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic