This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Firing a mouse clicked event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Firing a mouse clicked event" Watch "Firing a mouse clicked event" New topic

Firing a mouse clicked event

G Estes
Ranch Hand

Joined: Oct 22, 2002
Posts: 62
Is it possible to internally, fire a MouseClicked event, passing in a Point (or x,y coordinates) as to where that mouse click took place?
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Sure. Do you want to actually DO that click?
If you use the Robot class you can do a mouseMove(x,y) then a mousePress(button); and it will happen.
If you actually want to just stick something in the EventQueue it is a little more tricky.

"JavaRanch, where the deer and the Certified play" - David O'Meara
G Estes
Ranch Hand

Joined: Oct 22, 2002
Posts: 62
Thanks for your suggestion about the Robot class. Hadn't thought of that. What I'm trying to accomplish is to have a cell in a JTable be selected via the TAB key, so that the cursor shows itself and the full text of the cell is selected as well. I'm not sure the Robot class is the way to I should think something like editCell(row,col) should do it (but it's not).
Any other ideas?
G Estes
Ranch Hand

Joined: Oct 22, 2002
Posts: 62
I'm looking at creating a MouseEvent and using the processMouseEvent(MouseEvent ev) method of the JTable. When I create a mouse event, it asks for a time (when) of the event, but the documentation I'm seeing doesn't say much about format other than it is a long. Any enlightenment?
Bill Liteplo
Ranch Hand

Joined: Oct 16, 2002
Posts: 88
I agree. Here's the link:
subject: Firing a mouse clicked event
jQuery in Action, 3rd edition