package hello; import com.sun.lwuit.Button; import com.sun.lwuit.ButtonGroup; import com.sun.lwuit.CheckBox; import com.sun.lwuit.Container; import com.sun.lwuit.Display; import com.sun.lwuit.Form; import com.sun.lwuit.Image; import com.sun.lwuit.Label; import com.sun.lwuit.RadioButton; import com.sun.lwuit.layouts.BoxLayout; import com.sun.lwuit.layouts.GridLayout; import java.io.IOException; import javax.microedition.midlet.*; /** * @author Kanishka */ public class UIWidgetDemo extends MIDlet { public void startApp() { Display.init(this); try { Image img = Image.createImage("/img/cup.png"); //label Label lbl1 = new Label("My Label"); lbl1.setIcon(img); //buttons Button btn1 = new Button("Button1"); Button btn2=new Button("Button 2"); btn2.setIcon(img); //RadioButtons RadioButton rdb1=new RadioButton("Sri Lanka"); RadioButton rdb2=new RadioButton("India"); RadioButton rdb3=new RadioButton("Nepal"); //ButtonGroup ButtonGroup btnGrp=new ButtonGroup(); btnGrp.add(rdb1); btnGrp.add(rdb2); btnGrp.add(rdb3); //CheckBox CheckBox chkBx1=new CheckBox("C#"); CheckBox chkBx2=new CheckBox("Java"); CheckBox chkBx3=new CheckBox("C++"); CheckBox chkBx4=new CheckBox("Prolog"); CheckBox chkBx5=new CheckBox("LISP"); CheckBox chkBx6=new CheckBox("VB"); Form frm = new Form("Widget Demo"); frm.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); //creating containers Container btnCont=new Container(new GridLayout(1, 2)); btnCont.addComponent(btn1); Container chkBoxCont=new Container(new GridLayout(3, 2)); chkBoxCont.addComponent(chkBx1); chkBoxCont.addComponent(chkBx2); chkBoxCont.addComponent(chkBx3); chkBoxCont.addComponent(chkBx4); chkBoxCont.addComponent(chkBx5); chkBoxCont.addComponent(chkBx6); //adding components btnCont.addComponent(btn2); frm.addComponent(lbl1); frm.addComponent(btnCont); frm.addComponent(rdb1); frm.addComponent(rdb2); frm.addComponent(rdb3); frm.addComponent(chkBoxCont); frm.show(); } catch (IOException ex) { ex.printStackTrace(); } } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }
Sunday, January 15, 2012
J2ME with LWUIT (UI Toolkit Widgets) part 1
There are very important UI widgets available in LWUIT lets demonstrate them.
Applet
Labels:
Button,
ButtonGroup,
CheckBox. Widgets,
J2ME,
Label,
LWUIT,
Mobile,
RadioButton,
UI
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment