August 23, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Introducing a Lightweight UI Toolkit: Shake Your User Interface

  • September 25, 2008
  • 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.

...
weatherMid.getDownloadingPane().show();
   new Thread() {

      public void run() {
         YahooWeather weatherItem = getWeatherFromYahoo();
         final Form weatherForm = new Form();
         weatherForm.addCommand(backCommand);
         weatherForm.setCommandListener(actList);
         weatherForm.setBackCommand(backCommand);
         weatherForm.setSmoothScrolling(true);

         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,
                                   COMMAND_CITY));
         }

         initializeData(weatherItem, weatherForm);

         weatherForm.show();
      }
   }.start();
...

Transitions

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);
      mainMenu.setTransitionInAnimator(in);
   }

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

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.

Conclusion

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.

References

  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.


Tags: mobility



Page 7 of 7



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel