This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTable editing with double click + AbstractCellEditor Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "JTable editing with double click + AbstractCellEditor" Watch "JTable editing with double click + AbstractCellEditor" New topic
Author

JTable editing with double click + AbstractCellEditor

Mary Pana
Greenhorn

Joined: Aug 24, 2011
Posts: 3
Hi,

I have a JTable, custom cell editors obtained extending AbstractCellEditor.
Everything work fine.
However, the editing starts after a single click on the cell, but I want the editing to start after DOUBLE click.
I've seen there's a nice method in DefaultCellEditor : setClickCountToStart(int), but of course nothing similar for AbstractCellEditor.

Is there a way to start editing after a double click?
Ok I can detect double clicking using mouseEvent and using editCellAt(int,int), but of course the editing starts after the first click....

Thanks in advance!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Reimplement the cell editor's isCellEditable method. The implementation from DefaultCellEditor.EditorDelegate, which is what's being used by DefaultCellEditor:
There's the click count you were talking about.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Mary Pana
Greenhorn

Joined: Aug 24, 2011
Posts: 3
Thank you! Works like charm
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

You're welcome. Did you know that you can find the source yourself? It's in a file called "src.zip" that's located inside the JDK main folder.
Mary Pana
Greenhorn

Joined: Aug 24, 2011
Posts: 3
Rob Spoor wrote:You're welcome. Did you know that you can find the source yourself? It's in a file called "src.zip" that's located inside the JDK main folder.

I didn't!! thank you again and sorry for the late reply!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

No problem
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JTable editing with double click + AbstractCellEditor
 
Similar Threads
Highlight text of cell in JTable
How to goto a particular row /column in JTable
JTable catching JMeniItem accelerators
Jtable cell editing question
a q about JTable, implementing a CellEditor and changing the ComponentOrienation