java – Dispatch MouseEvent
•
Java
Is there any way to schedule mouseevent, just like using dispatchkeyevent
I know I have two choices
1) Add mouse events to all recursive components
2) Use transparent glass plate
Does Java support this, or do I have to use one of the above options?
thank you
Solution
You tried Java awt. Component. DispatchEvent (awtevent)?
import java.awt.*; import java.awt.event.*; import javax.swing.*; JButton jb = new JButton("Press!"); MouseEvent me = new MouseEvent(jb,// which MouseEvent.MOUSE_CLICKED,// what System.currentTimeMillis(),// when 0,// no modifiers 10,10,// where: at (10,10} 1,// only 1 click false); // not a popup trigger jb.dispatchEvent(me);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码