I've got a simple Swing GUI with JButtons being run on a Surface tablet with a touchscreen. The buttons have ActionListeners
. When these buttons are clicked from a mouse they visually depress correctly. However when they are tapped on the touchscreen they remain visually the same but still fire off an actionPerformed()
. If they are double tapped then they visually depress correctly but fire off 2 actionPerformed()
s.
Is there a way to get this button animation change to take place when the button is pressed, rather than clicked? I've tested it and I could use a MouseListener
and put all my logic in mouseClicked()
but it's not very elegant to ask touchscreen users to double tap a button.