This application demonstrates the use of touch events in Nokia Asha and Series 40 touch devices. It shows how to do high-performance touch event handling as well as circumvent touchscreen limitations by using simple mathematics. Additionally, some reusable custom UI components are introduced. The updated version features optimised UI for Nokia Asha software platform. This example application demonstrates:
Drawing on canvas
Saving an image in BMP format
Utilising multipoint touch
The application is hosted in GitHub:
For more information on the implementation, visit Java Developer's Library:
Java ME basics
Basic vector mathematics
Classes: Graphics, GameCanvas, Vector, Image, MultipointTouch
Painting requires high-performance touch event handling. This means you cannot immediately start drawing when the event comes, but must buffer the events and handle them in a separate thread.
Integration of multi-point touch requires handling different touch points and therefore adds some more complexity to the drawing. To ensure backwards compatibility, classes using the multi-point touch API need to be isolated properly, otherwise older devices will complain about missing class definitions.
On resistive screens multi-point touch is not really accurate enough for drawing.
This example was created with NetBeans 6.9.1 and built with Nokia SDK 2.0 for Java.
The project can be easily opened in NetBeans by selecting Open Project from the File menu and selecting the application.
Before opening the project, make sure the Nokia SDK 2.0 or newer for Java is installed and added to NetBeans. Building is done by selecting Build main project.
To install the application on a mobile device, transfer the JAR file via Nokia Suite or over Bluetooth.
The example can also be opened and run with Nokia IDE.
Draw by touching the white ‘drawing area’ on the screen. The tools, from left
to right, are clearing, saving, line thickness, colour, and exit. To save, touch the Save button. This opens a dialog where you can write the file name.
The file format is BMP. The application is closed with the Exit button. You can select from four different brush sizes by touching the brush tool. This changes
the brush tool's graphic to highlight the selected brush size. The colour tool opens the colour palette. Touching anywhere in the palette chooses the colour as the brush colour and closes the palette.
- Nokia Asha software platform 1.0 or later
- Series 40 6th Edition FP1 and newer.
- Nokia Asha 501 (Nokia Asha software platform 1.0)
Nokia Asha 305 (Java Runtime 2.0.0 for Series 40)
Nokia Asha 306 (Java Runtime 2.0.0 for Series 40)
Nokia Asha 308 (Java Runtime 2.0.0 for Series 40)
Nokia Asha 311 (Java Runtime 2.0.0 for Series 40)
- Nokia X3-02 (Series 40 6th Edition FP1)
Nokia SDK 2.0 Java
- 1.4 Removed reference to projects.developer.nokia.com
- 1.3.0 Ported to Nokia Asha software platform. Removed on-screen back buttons.
1.2.0 Improved drawing algorithm, added info screen and multi-point touch support. Series 40 full touch support added.
1.1.0 Image saving optimizations
1.0.0 First release