1

I'm trying to print something when the mouse button is clicked while the Java program is running. As far as I've seen, the MouseListener requires a Java Swing component, but I don't want to create an interface in which to click.

Note: I'm trying to print some Rhapsody diagrams when the mouse button is clicked and I can't do this if I have to click inside a Frame.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Daniel
  • 91
  • 1
  • 14
  • where do you expect to be able to catch the mouseclick? you really do need that UI component for it to work. – Stultuske Sep 14 '18 at 08:39
  • *I'm trying to print some Rhapsody diagrams*, but where exactly? –  Sep 14 '18 at 08:41
  • I have the IBM Rational Rhapsody app and my Java program console, both opened, I try to click on some diagrams in Rhapsody and through Java API I would like to print them in the opened console – Daniel Sep 14 '18 at 08:59
  • 1
    that's not possible, I'm afraid. the kind of Events you need, are limited. they work within the scope of the Java application they're supposed to work with, but, even if you have a Java compatible GUI, unless the component responsible for detecting and handling the event has the focus, it won't work. – Stultuske Sep 14 '18 at 09:15
  • I understand, that's probably why I didn't find anything about it on web. Thanks a lot, to both of you. Also, I don't know how to handle this situation on stackoverflow, could you help me? I mean, how do I close this thread (solved, unsolved..)? – Daniel Sep 14 '18 at 09:19
  • 3
    What about this: https://stackoverflow.com/questions/25496292/java-detect-mouse-clicks-anywhere-on-screen – Steve Smith Sep 14 '18 at 09:21

0 Answers0