Sunday, June 22, 2008

What Happened to My Widgets???

Your first reaction when looking at the new drop of LWUIT might be: what happened to my checkbox/radio button/combo box decoration and who do I blame?

That would be me. I changed the look of those 3 components so I'm to blame, but I have a good excuse. Previously the combo/radio button/checkbox elements were implemented as images drawn next to the particular entry. This looked very good in the looks and feels which we support by default, but this has several drawbacks:

1. Doesn't fit well with all look and feels and doesn't look equally good even in our own look and feels.

2. The obfuscator couldn't remove the image we used to draw these elements so you would pay the cost for all 3 elements even if you didn't use any of them in your application.

3. They wouldn't scale to match larger/smaller widgets.

The solution is to draw them using graphics primitives which solves all of the problems above and most specifically the look and feel problem. I know some of you will miss the old look and would want to keep it (or better yet use your own images...). For you guys we opened up a new set of API's in DefaultLookAndFeel to set the images that would be used in those situations specifically: setCheckBoxImages(Image, Image), setRadioButtonImages(Image, Image) & setComboBoxImage(Image).

So if you want your old checkboxes back just create the image objects and invoke the methods above, notice that changing the theme in the look and feel will not change these images...


  1. You don't need to create the default look and feel. The class is created for you and is accessible via the UIManager.getInstance().getLookAndFeel() method.

  2. Thanks alot Mr Shai :)
    it works perfectly now ... thanks a lot :)

    Best regards

  3. Dear LWUIT lover,

    Just to share my experience with LWUIT.
    1. When I developed LWUIT for less sophisticated mobile phone (those which only implements midp20.jar), I have to take out SVG related class from LWUIT.
    2. Regarding customizing CheckBox checked & unchecked images, I found that midp21.jar behaves different with midp20.jar. when using midp21.jar u have to switch the position from normal: .setCheckBoxImages(checkedImage, uncheckedImage) becomes .setCheckBoxImages(uncheckedImage, checkedImage)


  4. I am facing one problem in component of lwuit form. The problem is component behind the Soft-button is not displayed nor form scroll vertically when form height and mobile-display-height is equal, how can I solve this problem?