wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Double Click on Cell in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Double Click on Cell in JTable" Watch "Double Click on Cell in JTable" New topic
Author

Double Click on Cell in JTable

Suhas Mohamedali
Greenhorn

Joined: Jun 05, 2012
Posts: 29
Hi,

Please help me to handle the double click event in cell of JTable.
I added a mouse listener to the table.
The logic is written on mouseclicked method.
But it recognizes only one click. In the second click the cell becomes editable.

My requirement is to enter a code in the cell. If the user knows the code he can enter in the cell or he need to double click on the cell to open a search panel to search and fins the code.

Please help

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
initial thoughts are it would make more
sense to use the right-click to open a
search pop-up.

is there a specific reason to use a double-click
Suhas Mohamedali
Greenhorn

Joined: Jun 05, 2012
Posts: 29
Dear Michael,

Thanks for your reply.

Yeah we need to open the pop up using double click only as the existing application is so.
In the existing application the following code is used.

Could you please suggest???

column.setCellEditor(new MyEditor(new JTextField()))





Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

You could use javax.swing.DefaultCellEditor#setClickCountToStart() to set the click count to a large number; double-click won't initiate cell editing then.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Unless someone has a lot of patience
Integer.MAX_VALUE should be a safe enough value though.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Double Click on Cell in JTable
 
Similar Threads
Problem Regarding JTable
JTable
JTable Editing
MouseEvent on JTable
JTable