Touch sample app
The touch sample application demonstrates how to create and display an image that changes in response to customized touch events. If you touch the screen and slide your finger to another location on the screen, the application draws a line to trace the movement. You can click menu items to specify the width and color of the lines and to erase the canvas.
This file defines the TouchDemo class.
The TouchDemo class extends the UiApplication class to support a user interface and contains the following constructor and methods:
This file defines the TouchDemoScreen class and the ColorChangeDialog and WidthChangeDialog nested classes.
The TouchDemoScreen class extends the MainScreen class to support screen characteristics that are common to standard BlackBerry applications and contains the following constructor and methods:
The ColorChangeDialog and WidthChangeDialog nested classes both extend the Dialog class to support the basic functionality of a dialog box. ColorChangeDialog and WidthChangeDialog contain the code for creating dialog boxes that allow the BlackBerry device user to change the color and width of the line.
This sample features the following classes:
This class contains methods and constants for handling basic touch events that the BlackBerry device user inputs.
The sample application demonstrates how to use the getX() and getY() methods to retrieve the location of the touch event and the getEvent() method to identify the type of touch event.
This class contains the method touchEvent(TouchEvent message), which is invoked to handle touch events when they occur on a Screen object.
The sample application demonstrates how to override this method to customize the behavior of touch events. In the sample application, when a TouchEvent.MOVE event follows a TouchEvent.DOWN event, the application draws a line on the screen to trace the movement.
Install the sample app
Visit www.blackberry.com/go/touchsample to download the sample application.
Extract the touchdemo.zip file.
On the taskbar, click Start > Programs > Research In Motion > BlackBerry JDE 4.7.0 > JDE.
Open the workspace that you want to add the sample application to.
In the workspace tree, right-click the project that you want to add the sample application to.
Click Add project to <workspace directory>.
In the Add project to <workspace> dialog box, browse to the folder where you extracted the sample application.
Click the touchdemo.jdp file.
The sample app is also available in github.
Run the sample app
In the workspace where you added the touchdemo project, right-click touchdemo.
Click Build project.
On the taskbar, click Start > Applications > Research in Motion > BlackBerry JDE 4.7.0 > Device Simulator.
On the Home screen of the BlackBerry Smartphone Simulator, click the Downloads folder.
Click the Touch Demo icon.