Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to trigger a mouse event with out MouseListener

 
Varatharuban B
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Varatharuban B
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could call dispatchEvent(AWTEvent e) and pass it a MouseEvent.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic