[back to projects]
touchscreen.jar includes source (with javadoc), runs the test applet when double-clicked
it's pretty simple to add touch screen stuff to your code. you must implement the interface TouchScreenApplication, which gives you the callback function touchHappened(Touches touches). create a TouchReceiver, passing it a reference to your app (ie TouchReceiver touchReceiver = new TouchReceiver(this);).
then, every time something happens on the screen, you'll be passed a Touches. this class extends ArrayList, and is a list of Touch-es. a Touch represents a hand on the screen somewhere, and has public ints x and y for the top-left of the hand, w and h for the width and height of the hand, and a status. status can be:
important: after you use the Touches data, be sure to call touchReceiver.update(), which tells the TouchReceiver that you've seen the data, and it is safe to receive more touches. this is done to ensure that you see all JUST_WENT_UP touches.
- JUST_WENT_DOWN: this Touch just started
- IS_DRAGGING: this Touch has been down and is dragging across the screen
- JUST_WENT_UP: this Touch ended last frame - the user's hand left the screen.
please help out!
do you have a much better example applet than mine? should the API be changed? suggestions are welcome - this thing was hacked together very quickly. send mail to kevin dot cox, at our university's domain