February 27, 2021
Hot Topics:

Introducing a Lightweight UI Toolkit: Shake Your User Interface

  • By Ibon Urrutia
  • Send Email »
  • More Articles »

Every time you have to go to the Yahoo weather site to download information, you do the same thing: Get the downloading Form, and then create a new thread that downloads requested information, parses it, and creates a new Form that finally is shown. So, while EDT is painting your downloading form, showing it on screen, you are creating the new screen to be shown.

   new Thread() {

      public void run() {
         YahooWeather weatherItem = getWeatherFromYahoo();
         final Form weatherForm = new Form();

         Vector citiesStored = actList.getCities();
         YWRecord lastRecord = (YWRecord) citiesStored.elementAt(0);
         for (int i = 0; i < citiesStored.size(); i++) {
            YWRecord city = (YWRecord) citiesStored.elementAt(i);
            weatherForm.addCommand(new Command(city.name,

         initializeData(weatherItem, weatherForm);



In addition to the capability of animating every component, you also have the possibility of animating when you are leaving and entering a Form. With those transition effects, is very easy to create an overall 3D sensation, as you did in your Midlet.

private void setInRotation(boolean right) {
      in = Transition3D.createCube(TRANSITION_RUN_SPEED, right);

   private void setOutRotation(boolean right) {
      out = Transition3D.createCube(TRANSITION_RUN_SPEED, right);

You are changing the direction of a 3D cube's rotation to simulate a three face prism: The Location Form is placed on the right face, and the Weather Form on the left. Take care that, if you want to use Transition3D class, your target devices require M3G (JSR 184) support, which is very common today.


In this series of two articles, you have made a basic application that serves as introduction to the LWUIT library. You have seen how components are placed on containers, how you include resources inside an application, and some of the effects you can use in your own applications. I just want to recommend the excellent blog of one of the developers of LWUIT, Shai Almog [3], where you will find a lot of advanced tips and where new features developed on releases of LWUIT are explained in detail.

Download the Code

You can download the code that accompanies this article here.


  1. First article of this series: http://www.developer.com/ws/article.php/3759471
  2. Yahoo weather API description: http://developer.yahoo.com/weather/
  3. Shai's Java / LWUIT Blog: http://lwuit.blogspot.com/

About the Author

Ibon Urrutia is a Spanish IT Engineer with wide experience in JavaME applications targeted to be used in many devices. Nowadays, he works for MDTEC http://www.mdtec.net, participating in a complete JavaME framework with advanced user interface functionalities, TagsMETM http://www.tagsme.com. He also is member of Netbeans Dream Team http://wiki.netbeans.org/NetBeansDreamTeam.

Page 7 of 7

This article was originally published on September 25, 2008

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date