![]() To make sure the implementation that you are working on supports touchscreen gestures, you can use the hasPointerEvents() and hasPointerMotionEvents() methods. By providing an empty implementation of the pointerDragged(int x, int y), pointerPressed(int x, int y), and pointerReleased(int x, int y) methods, the implementation of these methods has been left to your code. You have to double-check with the device manufacturer's documentation to see what works best. A touchscreen device from Motorola, for example, might not respond very well to a user's fingers as the primary pointing device, but a device from Nokia might. Of course, all of this is Canvas class implementation-specific. The initial idea of these methods was to deal with interfaces that were pointer enabled, that is, the user interacted with the interfaces using a pointing device (hence, the use of pointer), but these methods work just as well in nonpointing devices that are touch-enabled. ![]() These methods are hasPointerEvents(), hasPointerMotionEvents(), pointerDragged(int x, int y), pointerPressed(int x, int y), and pointerReleased(int x, int y). Instead of the paint(Graphics g) method, in this article, we are interested in five other methods that help us to build touchscreen interfaces. For a link to a full tutorial on the Canvas class, see the See Also section. The most important of these methods is the paint(Graphics g) method, which does the actual drawing of the graphics. The class itself is abstract and actual implementations must override methods that they are interested in. The Canvas class is in the package and provides low-level screen and graphic manipulation methods. Java technology has, of course, provided the means to capture touch events from almost the beginning of Java ME (MIDP 1.0, when it was called J2ME) through the Canvas class. Touchscreen has come a long way since then, and Apple's iPhone, iPad, and iPod have brought about a revolution in screen manipulation using touch. I used to own a Palm Pilot-type device back in 1999 that had a doodle with which to draw on the screen and make gestures. The idea of touchscreen interfaces is not new, of course. I will also create an application that will exercise the basic touch interface methods in Java ME and then build on the application to create an image scrolling application. In this article, I will introduce you to the methods in the Canvas class that work well with devices that have touch interfaces. Since the launch of the evil "no Java Virtual Machine available" iPhone, almost every mobile manufacturer has released a mobile phone that has a touch interface. Now I have to figure out how to make her stop trying to do that at home on my computer screen (or buy her an iPad). The idea of touch was enough to enable her understand what she was doing. The delight on her face was instantaneous when she realized she could use her fingers to move the images and type and she did not need any interface other than her hands. She could not understand why the letters didn't move. After using her fingers to draw, mold, and paint, she moved on to touching my computer screen to move the letters she typed. Our senses are our most important tools, and my daughter is using all her senses to the maximum these days. You see, I thought for a bit about how to introduce this article on touchscreen UIs in Java Platform, Micro Edition (Java ME). ![]() It can also give you ideas for your work, which is why I am telling you this story. In a world where everything is going crazy at the same time, a bit of horseplay with kids can give us a real sense of priorities. ![]() Suddenly, I hear and feel some banging on the outside of the box that goes right through my head and I wonder if this will be the last time I use the diaper boxes to play make-believe with my 2-year-old daughter. My head is inside a big box, and I feel claustrophobic. ![]()
0 Comments
Leave a Reply. |