wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes How to trigger a mouse event with out MouseListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to trigger a mouse event with out MouseListener" Watch "How to trigger a mouse event with out MouseListener" New topic
Author

How to trigger a mouse event with out MouseListener

Varatharuban B
Greenhorn

Joined: Feb 04, 2008
Posts: 5
Hi

Is there any way to trigger any MouseLister callback methods (mouseClieked(), mousePressed(), etc ...) without MouseListener ?

OR
Can I call mouseClicked(MouseEvent e) method manually ? If YES, how can I pass the MouseEvent ?

Can any one please help me ?

Thanks in advance

Regards
Varatharuban
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I guess you're talking about Swing ? On which component do you want to do that ? Some components, like JButton, have a doClick() method to simulate a mouse click.


[My Blog]
All roads lead to JavaRanch
Varatharuban B
Greenhorn

Joined: Feb 04, 2008
Posts: 5
Yes. This is based on JApplet.
But I have to generate or call that mouseClicked() event without any mouse events.
Can I generate the same method using programming, with out event ?

Thanks
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

You could call dispatchEvent(AWTEvent e) and pass it a MouseEvent.
 
GeeCON Prague 2014
 
subject: How to trigger a mouse event with out MouseListener