0

Are there alternatives to AWT for getting mouse press events in Java?

user3469157
  • 129
  • 2
  • 8

2 Answers2

1

Mouse event implies there's a window / frame on which the event occurred. Typically each GUI toolkit comes with its own list of event listeners / dispatchers. So the question should really be: "What are the alternatives to AWT?"

  1. There's Swing. You can read about the difference between AWT and Swing here . (The answer also mentions SWT:

Finally, you might also want to check out SWT (the GUI toolkit used for Eclipse, and an alternative to both AWT and Swing), which is somewhat of a return to the AWT idea of accessing native Widgets through Java.

  1. There's JavaFX, which is a more rich graphics framework and somewhat a successor of Swing. You can read about it on official Oracle JavaFX page here .

If we are talking about specific frameworks then (as far as I know they still use AWT event system underneath):

  1. JMonkey game engine. Official Page

  2. LWJGL. Light weight java gaming library. Official Page

There are probably other frameworks but it seems the core functionality comes from AWT to handle native mouse query.

Community
  • 1
  • 1
AlmasB
  • 3,377
  • 2
  • 15
  • 17
  • another noteworthy alternative is qtjambi, which is QT for Java – scottysseus Jun 03 '15 at 12:57
  • I have a Swing GUI but AWT mousePressed events are failing me so looking to see if there is another toolkit I could use to get those events for the swing GUI rather than AWT. – user3469157 Jun 03 '15 at 16:27
0

Since I found lots of unanswered threads on this I'll share the solution. Turns out Windows 7 defaults Java to wm_gesture rather than wm_touch events so AWT does not get press events as expected. What you need to do is use JNA to register the window as a touch window (https://msdn.microsoft.com/en-us/library/windows/desktop/dd317326(v=vs.85).aspx).

user3469157
  • 129
  • 2
  • 8