B
Brian J. Sayatovic
I've got a JTable that I'd like to have invoke an Action when a user
double-clicks on a row. I found code on Google to get me started on
adding a MouseListener to the table, checking the click count and
calculating the clicked row. What I'm stuck on is how to invoke the
action.
My code is in such a way that I do have a reference to the Action
instance readily available. But, to invoke it, I need to call
Action.actionPerformed(ActionEvent). I'm uncertain of how to construct
the ActionEvent.
I've used the MouseEvent's source and id to construct the ActionEvent.
I've used a hard-coded action name for now ("EDIT"). But what about
the modifiers? At this time, I'm not concerned about a keymask, btu I
may be in the future.
The MouseEvent's constants for the key masks from from
java.awt.event.InputEvent constants. But the ActionEvent class defines
its own constants for the key masks. Are these two compatible?
Is there a better way to achieve my end goal of invoking the edit
Action when a row is double-clicked?
Regards,
Brian.
double-clicks on a row. I found code on Google to get me started on
adding a MouseListener to the table, checking the click count and
calculating the clicked row. What I'm stuck on is how to invoke the
action.
My code is in such a way that I do have a reference to the Action
instance readily available. But, to invoke it, I need to call
Action.actionPerformed(ActionEvent). I'm uncertain of how to construct
the ActionEvent.
I've used the MouseEvent's source and id to construct the ActionEvent.
I've used a hard-coded action name for now ("EDIT"). But what about
the modifiers? At this time, I'm not concerned about a keymask, btu I
may be in the future.
The MouseEvent's constants for the key masks from from
java.awt.event.InputEvent constants. But the ActionEvent class defines
its own constants for the key masks. Are these two compatible?
Is there a better way to achieve my end goal of invoking the edit
Action when a row is double-clicked?
Regards,
Brian.