I have a JTree with a custom MouseListener (to display a popup, etc.). I need to run MouseEvent , which will be caught by MouseListener . How to do this programmatically?
JTree
MouseListener
MouseEvent
You can create your own MouseEvent and skip all listeners and make a call.
For instance:
MouseEvent me = new MouseEvent(tree, 0, 0, 0, 100, 100, 1, false); for(MouseListener ml: tree.getMouseListeners()){ ml.mousePressed(me); }
The Robot class may be what you are looking for.
This class is used to generate your own system input events in order to automate testing, self-running demos and other applications that require mouse and keyboard control. Robot's main goal is to facilitate automated testing of Java platform implementations.
Source: https://habr.com/ru/post/893673/More articles:Failed to access jarfile./lib/proguardgui.jar - androidCreated in JavaDoc - javaHow to run a JPA request in a gaming platform - hibernatehow to find out if an element has already been pressed by jquery - jqueryJavascript functions, how can I start to understand them? - javascriptHow to transfer RFID tags using IDBlue RFID pens using iPhone? - iphoneHow to POST new data in CouchDB using JavaScript / jQuery - javascriptProblems with Couchdb cors - javascriptMemory problems when displaying large images in UITableView - memory-managementLike Marshal.ReadInt32 etc. Differ from insecure context and pointers? - c #All Articles