Hi all,
does anyone know how to handle the double click event on a JTable?
I wrote the following code:
table.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() == 2)
some_statement;
}
});
but it works only if I click on the lines of the table and it doesn't if
I click in the middle of a cell.
Murray - 30 Jul 2004 18:08 GMT
> Hi all,
> does anyone know how to handle the double click event on a JTable?
[quoted text clipped - 12 lines]
> but it works only if I click on the lines of the table and it doesn't if
> I click in the middle of a cell.
Hmm doesn't seem like a database problem .. maybe you should try
comp.lang.java.gui ;-)
alexjcasol - 30 Jul 2004 23:27 GMT
Got it!
The metter is the doubleClick on a cell.
By the double click you get the cell opened in edit mode and you loose the
control.
But if you check the Release event you get the control again just because
it happens after the click.
That's why it worked on the lines of the grid and it didn't on the cells.
I wrote the following code and it works.
table.addMouseListener(new MouseAdapter()
{
public void mouseReleased(MouseEvent e)
{
if (e.getClickCount() == 2)
{
table.getCellEditor().stopCellEditing();
My.Statement;
}
}
});
thank you for your kindness!
By Alessandro
Christophe Vanfleteren - 30 Jul 2004 22:46 GMT
> Hi all,
> does anyone know how to handle the double click event on a JTable?
[quoted text clipped - 12 lines]
> but it works only if I click on the lines of the table and it doesn't if
> I click in the middle of a cell.
select * from double_click where is_middle_of_cell = true;
Or you could just try c.l.j.gui instead :)

Signature
Kind regards,
Christophe Vanfleteren