-2

I would like to print component coordonate on which the user is clicking. I can not modify the interface (consider it as part of an external module). I need to plug my code at runtime.

So far I have wrote a snippet to add a MouseClickListener that is adding a action performed to display the X and Y, and I iterate on every component to add it. This is not ideal, I need to call the code regularly to add a listener to new instantiated container. This is plainful to handle.

Would there be other solution like agent or maybe intercept AWT events ?

LeGLL
  • 111
  • 1
  • 8
  • Of course you would need a MouseListener, not an ActionListener. Please tell the details of your code and your problem. Exactly what components need the listener? How is this question different from one asking "what is a MouseListener"? – Hovercraft Full Of Eels Aug 06 '23 at 14:33
  • Added edit. The gui is part of a jar that I cannot modify. Listeners could be a solution but it has drawbacks, I am looking for other options. Agent looks overkill, would there be something easier to do ? – LeGLL Aug 06 '23 at 21:23
  • I guess you understood that I needed someone to fill comment. Let me add dummy code so it get clear that this is not what I am looking for – LeGLL Aug 06 '23 at 21:27

0 Answers0