The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

This topic is READ ONLY
import-bot (20211) [Avatar] Offline
#1
[Originally posted by cjacobs]

Hi,

is there a way for me to controll the number of clicks needed to start editing
a JTable cell.

I would prefer to start editing using the right mouse click.

Do I have create my own custom cell editor class that listens to the type of
mouse clicks I want to start editing of a cell?
import-bot (20211) [Avatar] Offline
#2
Re: Mouse events and JTable cells
[Originally posted by cjacobs]

> Hi,
>
> is there a way for me to controll the number of clicks needed to start editing
> a JTable cell.
>
> I would prefer to start editing using the right mouse click.
>
> Do I have create my own custom cell editor class that listens to the type of
> mouse clicks I want to start editing of a cell?


Hi, I took my ownn suggestion and create a custom cell editor, and in my
isCellEditable() method I test for the mouse clicks. It works!

However, when I try to detect a right mouse click with my right mouse button
using SwingUtitlies.isRightMouseButton( MouseEvent evt ) it does not work.

Instead, when both mouse buttons are clicked, then I receive an event
notification i.e (System.out.println( "debuging text" ) );

When I try to detect a middle mouse click( for two mouse
buttons---simutaneously depressing right and left) using
SwingUtilities.isMiddleMouseButton( MouseEvent evt ) it does not work. It
works only with the Alt key and the left mouse button (simutaneously depress).


The isLeftMouseButton(MouseEvent evt ) works well.

Here is my method:

public boolean isCellEditable( EventObject evt ) {
MouseEvent mouseEvent = (MouseEvent)evt;
if( SwingUtilities.isRightMouseButton(mouseEvent) ) {
System.out.println( "I am clicked" );
return true;
}
else
return false;
}


I am confuse. Please, any help would be greatly appreciated.

Thanks in advance,

_CJ