Your browser does not support JavaScript
Exit Print View

Lightweight UI Toolkit Developer’s Guide

Get PDF Book Print View

Document Information


1.  Introducing the Lightweight UI Toolkit Library

2.  Using Lightweight UI Toolkit Widgets

3.  Using Lists

4.  Table and Tree

5.  Using Dialogs

6.  Using Layout Managers

7.  Painters

8.  Using the Style Object

9.  LWUIT Implementation

10.  HTMLComponent

11.  Theming

12.  Resources

13.  Using Transitions and Animations

14.  M3G

15.  Logging

15.1 Writing to a Log

15.2 Showing the Log

16.  Authoring Components

17.  Portability and Performance



Chapter 15


Adding logging statements into your code is the simplest debugging method. The logging framework allows you to log into storage (RMS) or your file system at runtime without changing your binary. There are four debugging levels to help you better monitor your code: DEBUG, INFO, WARNING and ERROR.

You should use the Log class coupled with NetBeans preprocessing tags to reduce its overhead completely in runtime. For information on the Log class, see com.sun.lwuit.util.Log in the LWUIT API documentation.

15.1 Writing to a Log

To write into a log, you use the static p(String text) or p(String text, int level) methods. For example:

Log.p(“Finish loading images”)

15.2 Showing the Log

To print out the log, use the static showLog() method. If you are using, the log is written to the root location as the file file.log. If you don't use a file connection, a new Form appears with the log text inside.

The following example shows how to work with NetBeans preprocessing tags:

// In case you are in debug mode, import Log class
// #debug
import com.sun.lwuit.util.Log;
// Here is how to surround a log method, inside your code
// #mdebug
if(keyCode == Canvas.KEY_POUND) {

Using preprocessing tags reduces the size of the source code, which is an important issue in mobile development. For more information, please refer to NetBeans information on preprocessing tags.