Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Double Click on Cell in JTable

 
Suhas Mohamedali
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless someone has a lot of patience
Integer.MAX_VALUE should be a safe enough value though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic