# Lab-5539: Touch your application! - Building slick, touch-enabled UIs for Java ME

Expected Duration: 100 minutes
Contacts: Karol Harezlak Lukas Hasik Brad Schmidt

Introduction | Exercise 0 | Exercise 1 | Exercise 2 | Exercise 3 | Exercise 4 | Summary
Introduction Background Information Steps to Follow Summary ## Exercise 4: Running the Application Using a Touch Screen Enabled Device Emulator This exercise provides instructions for enabling the Sun Java Wireless Toolkit 2.5.2 to run applications in touch screen enabled mode. In this exercise we are going to alter the Wireless Toolkit properties so it can emulate a touch screen device. This will allow us to run and test the behavior of the SVG Rich Components as if it were running on a touch screen device. ### Background Information #### The Sun Java Wireless Toolkit 2.5.2 and Java ME SDK 3.0 The Sun Java Wireless Toolkit 2.5.2 (WTK) that is bundled with NetBeans is a tools set for creating Java applications that run on devices compliant with the Java Technology for the Wireless Industry (JTWI, JSR 185) specification and the Mobile Service Architecture (MSA, JSR 248) specification. It includes build tools, utilities, and a MIDP/CLDC device emulator that supports both touch enabled and standard device emulation. The Java ME SDK 3.0 has just been released and combines the functionality included in the CLDC/MIDP Wireless Toolkit with the Sun Java Toolkit for CDC 1.0 along with many other new features to support development for the broadest possible number of Java enabled devices. NetBeans 6.7 will be bundled with the Java ME SDK 3.0, but only for the Windows platform. The Linux, MacOS and other distros will still include the WTK 2.5.2. ### Steps to Follow Step 1: Enabling touch screen behavior in the WTK 2.5.2 emulator To activate touch screen emulation in the WTK we have to modify one of the device configurations. In this lab it will be the DefaultColorPhone configuration. The properties of a particular configuration are stored in a file named to represent the type of device: Name_of_device.properties. The property file we need to modify in this excercise is DefaultColorPhone.properties. Go to the folder WTK_HOME_FOLDER\wtklib\devices\DefaultColorPhone and locate the configuration file DefaultColorPhone.properties Troubleshooting Tip: You can verify the directory location of the WTK by checking the Project Properties of the SVG application we created. Open the DefaultColorPhone.properties using the WordPad text editor and change the value of property touch_screen to true. Note: If you are using the Java ME SDK 3.0 it is not necessary to modify the properties file to enable touch screen emulation. After restarting the WTK we are ready to test our application in a touch enabled enviroment. Step 2: Running the application and verifying that touch screen behavior is enabled In NetBeans go to Run > Run Main Project (F6) When the application is launched in the emulator you can verify that touch screen properties are enabled by placing the mouse pointer over the SVG Components. The mouse cursor will appear as a cross and can be moved around the screen to navigate the application menus as a user would do with their fingertip. You can peform some basic UI tests with touch screen enabled such as using the Previous or Next button. You can even alter the age and gender of the contact name to verify that these UI elements are working properly. Step 3: Running the application in the Java ME SDK 3.0 emulator. Note: this is an optional step for those who have the Java ME SDK 3.0 downloaded and installed already. In order to launch the application in the Java ME SDK 3.0 or other touch screen device emulator we need edit the the Project Properties. Right-click the Project node and choose Properties from the contextual menu. In the Project dialog under Category choose Platform then select Java Platform Micro Edition SDK 3.0 from the Emulator Platform drop down menu. For touch screen device emulation select DefaultFxTouchPhone1 from the Device drop down menu as shown below and click OK. Go to Run > Run Main Project (F6) and the application launches in the emulator. In the emulator we can perform some basic UI tests such as using the Previous or Next button to verify that the UI elements are working properly. ### Summary In this exercise, you learned how to activate the touch screen properties in the WTK 2.5.2. We also verified that the SVG Rich Components were touch enabled in both the WTK 2.5.2 and Java ME SDK 3.0 emulators. The application is now ready to be deployed to SVG capable touch screen devices. Back to top Summary