9

I would like to know what events my buttons in the UI of my application should have listen to? To mouse click? And what about the pressing and releasing events? Are they the same while clicking via touch screen?

Thanks, Tomer

tomericco
  • 1,544
  • 3
  • 19
  • 30

1 Answers1

10

Most touchscreens simply emulate a mouse, so if your needs are simple you don't need to do anything special - JButtons still fire ActionEvents, combo boxes still fire ItemEvents, etc. If you want to do anything fancy (multitouch, flick-scrolling, etc.) then you can use the regular mouse events (mouseClicked, mousePressed, mouseDragged etc.) and provide your own gesture logic, or take a look at the libraries suggested in the answer for this similar question.

Community
  • 1
  • 1
Stewart Murrie
  • 1,319
  • 7
  • 12
  • I want only to imitate the behavior of MouseClicked, MousePressed, MouseReleased in touch screen (without multi-touch and stuff) - From what I know only the ActionPerformed event is supported by our touch screen. So the only way to imitate all the events that I want is to use something like MT4j ? – tomericco Jan 16 '11 at 20:19
  • No, I should think you'd be able to register MouseEvent listeners with any component. Have you tried this and it doesn't work? What touchscreen are you using? – Stewart Murrie Jan 16 '11 at 20:50
  • I am wondering if touch screens are firing mouseMoved() or mouseDragged()? That would solve many quesitons. – Ilian Zapryanov Jan 16 '14 at 20:19