You are on page 1of 24

LIGHTWEIGHT UI TOOLKIT -

MAKING COMPELLING JAVA™ ME APPLICATIONS EASY

Chen Fishbein, Software Architect


Shai Almog, Software Architect
Yoav Barel, Senior Manager
TS-4921
Agenda

What is LWUIT?
Why?
Key Benefits
Key Features
Demo
Samples
Tools
Advanced Concepts
Get Started
Q&A

2008 JavaOneSM Conference | java.sun.com/javaone | 2


What Is LWUIT?

Lightweight library bundled with the


application
Compelling UI
Consistent across different devices
Today's handsets MIDP 2.0/CLDC 1.1
only requirement!
Inspired by Swing
Resource editor

2008 JavaOneSM Conference | java.sun.com/javaone | 3


Why?

Developed in-house to support


project Hydrazine
Complex UI requirements on
existing devices
High portability
Developer's feedback
Bridges the gap between today
and tomorrow

2008 JavaOneSM Conference | java.sun.com/javaone | 4


Key Benefits

Rapid development
• Familiar API
• Clean & Simple
Easy deployment
• One JAR – many devices
Mass market devices
Consistent
Extendable
Filthy Rich UI
Brand-able

2008 JavaOneSM Conference | java.sun.com/javaone | 5


Key Features
Swing Like MVC Painters
Layouts Modal Dialog
PLAF & Themes Synchronous Model
Fonts External Tools
Touch Screen I18N/L10N
Animations & Transitions
Rich widgets
3D Integration

2008 JavaOneSM Conference | java.sun.com/javaone | 6


Approach

2008 JavaOneSM Conference | java.sun.com/javaone | 7


LWUIT Demo

2008 JavaOneSM Conference | java.sun.com/javaone | 8


LWUIT Demo

2008 JavaOneSM Conference | java.sun.com/javaone | 9


Samples – Hello World

Form frm = new Form(“Hi”);


frm.addComponent(new Label(“World”));
frm.addCommand(exitCommand);
frm.show();
Now Make It Beautiful...

Resources r = Resources.open(“/myTheme.res");
UIManager.getInstance().setThemeProps(r.getTheme(“theme”);

2008 JavaOneSM Conference | java.sun.com/javaone | 10


Samples – List

Form frm = new Form(“List”);


frm.setLayout(new BorderLayout());
List lst = new List(new String[] {
“Item 1”, “Item 2”, “Item 3”, “Item 4”
});
lst.setListCellRenderer(new MyRenderer());
frm.addComponent(BorderLayout.CENTER, lst);
frm.addCommand(exitCommand);
frm.show();

2008 JavaOneSM Conference | java.sun.com/javaone | 11


Samples – Renderer
class MyRenderer extends Label implements ListCellRenderer {
private Image sady, smily;
...
public Component getListCellRendererComponent(List list,
Object value, int index, boolean isSelected) {
setText(value.toString());
setFocus(isSelected);
if (isSelected) {
setIcon(sady);
getStyle().setBgTransparency(100);
} else {
setIcon(smily);
getStyle().setBgTransparency(0);
}
return this;
}
public Component getListFocusComponent(List list) {
return getListCellRendererComponent(list,"",0,true);
}
}
2008 JavaOneSM Conference | java.sun.com/javaone | 12
Samples – Renderer (cont)

2008 JavaOneSM Conference | java.sun.com/javaone | 13


Samples – Form
Form frm = new Form(“Survey”);
frm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
frm.addComponent(new Label(“Are you happy?”));
final RadioButton yes = new RadioButton(“Yes”);
RadioButton no = new RadioButton(“No”);
frm.addComponent(yes);
frm.addComponent(no);
ButtonGroup bg = new ButtonGroup();
bg.add(yes); bg.add(no);
Button submit = new Button(“Submit”);
frm.addComponent(submit);
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
String text = “Too bad :-(“;
if(yes.isSelected()) {
text = “Yay!!!”;
}
Dialog.show(“Result”, text, “OK”, null);
}
});
frm.show();
2008 JavaOneSM Conference | java.sun.com/javaone | 14
Resource Editor
Optional Tool
Built For Designers
Standalone
Resources:
• Themes
• Fonts
• Animations/Images
• Localization
• Arbitrary Data
LWUITDemo “live
preview”
2008 JavaOneSM Conference | java.sun.com/javaone | 15
Matisse GUI Builder
Award Winning,
Mature
Group Layout –
Baseline alignment
Relative spacing/grow
Event Handling Code
D&D/C&P
Styles & Themes
Component Palette
Custom Components
2008 JavaOneSM Conference | java.sun.com/javaone | 16
Tools Demo

2008 JavaOneSM Conference | java.sun.com/javaone | 17


Advanced Concepts

Uses native rendering engine


Renders onto GameCanvas
Optional M3G rendering integration
Planned: SVG support
Abstracts physical motion
Animations/Transitions based on
internal engine
Threading approach of Swing coupled
with builtin Foxtrot
Single EDT for rendering and events

2008 JavaOneSM Conference | java.sun.com/javaone | 18


Performance & Portability

Testing heavily on Sprint devices,


Nokia, SE, Motorolla and phoneME
Many additional phones are tested
Designed for small size/overhead
Most overhead is in resources
IndexedImage & light mode for low
end
Doesn't require preprocessor

2008 JavaOneSM Conference | java.sun.com/javaone | 19


Footprint

Jar size as low


as 50kb for a
small application
Memory depends
on theme/functionality/resolution
UI Demo runs on 320x240x24bpp Nokia S40
using under 1mb and no more than 2mb
Themes can be light or heavy depending on
their features

2008 JavaOneSM Conference | java.sun.com/javaone | 20


FAQs ...
MIDP 2.0 devices support LCDUI, why do I need LWUIT?
• LWUIT offers a rich UI alternative that sits on top of MIDP
• Both complement each other and LWUIT remains strictly optional
Will I need to learn a new API?How similar is it to Swing?
• LWUIT was inspired by Swing. Developers should find it easy to move
between LWUIT and AGUI/Swing APIs
How will LWUIT assist me in dealing with fragmentation?
• LWUIT is Implemented on top of Canvas therefore highly portable
• Not a device API but bundled together with the application
There are other UI toolkits out there – why LWUIT?
• We believe LWUIT offers very attractive functionality for developing
consistent and compelling Java ME apps
• LWUIT remains strictly optional
• Due to the open source nature of LWUIT we hope cross-pollination
will occur for the benefit of the entire industry
2008 JavaOneSM Conference | java.sun.com/javaone | 21
Get Started

Early access on java.net (binary)


http://lwuit.dev.java.net
Online Tutorial
Available in Sprint WTK 3.3
Come visit us at: The Mobility
Village pod
Please send us feedback
Open Source soon!!!

2008 JavaOneSM Conference | java.sun.com/javaone | 22


Q&A

2008 JavaOneSM Conference | java.sun.com/javaone | 23


Chen Fishbein, Software Architect
Shai Almog, Software Architect
Yoav Barel, Senior Manager
TS-4921

2008 JavaOneSM Conference | java.sun.com/javaone | 24

You might also like