Files in the sample application

TouchDemo.java

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:

  • main(String[] args): provides the entry point to the sample application and starts the main thread for the application using enterEventDispatcher() from UiApplication
  • TouchDemo(): constructs a new TouchDemo object, and contains the code to check if the BlackBerry® device has a touch screen using the Touchscreen.isSupported() method, and if it does, creates a TouchDemoScreen object and displays it

TouchDemoScreen.java

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:

  • TouchDemoScreen(): constructs a new TouchDemoScreen object, and contains the code that initializes an SVGImage object and creates and adds menu items for erasing the screen and for changing the width and color of the line
  • touchEvent(TouchEvent message): overrides the Screen class's implementation of the touchEvent(TouchEvent message) method so that when a touch event occurs, the sample application identifies the location and type of touch event, and performs actions depending on the type of touch event
  • drawLine(String color, int width, int x, int y): draws lines that trace TouchEvent.MOVE events
  • sublayout(int height, int width): overrides the Manager class's implementation of sublayout(int height, int width) to set the layout of the screen and the viewport dimensions of the SVGImage object depending on the orientation of the BlackBerry device
  • paint(Graphics graphics): overrides the Field class's implementation of the paint(Graphics graphics) method to repaint the screen each time a TouchEvent.MOVE event occurs

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.

Resource files

File

Description

img/TouchDemo_jde.png

This file is the application icon for the sample application.

TouchDemo.jdp

This file is the project file for the sample application.

Next topic: System requirements
Previous topic: Featured classes

Was this information helpful? Send us your comments.