1. Introducing the Lightweight UI Toolkit Library
2. Using Lightweight UI Toolkit Widgets
13. Using Transitions and Animations
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.
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”)
To print out the log, use the static showLog() method. If you are using microedition.io.file.FileConnection, 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) { Log.showLog(); } //#enddebug
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.