First 3pgms
First 3pgms
public class HelloMIDlet extends MIDlet { public void startApp() { S stem.out.println(!Hello "orld!); # public void pauseApp() { # public void destro App(boolean unconditional) { # #
OR
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*; public class HelloWorld extends MIDlet{ private Form form; private Display display; public HelloWorld !{ super !; " public void start#pp !{ form $ ne% Form &Hello World&!; 'trin( ms( $ &Hello World)))))))&; form.append ms(!; display $ Display.(etDisplay t*is!; display.set+urrent form!; " public void pause#pp !{" public void destroy#pp boolean unconditional!{ notifyDestroyed !; " "
CommandExample import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class CommandExample extends MIDlet implements CommandListener{ private Form form; private Displa displa ; private Command o!" bac!" cancel" exit" #elp" item" screen" stop; public CommandExample$%{ form & ne' Form$(Command Form(%; screen & ne' Command$()C*EE+(" Command.)C*EE+" ,%; bac! & ne' Command$(-.C/(" Command.-.C/" 0%; cancel & ne' Command$(C.+CEL(" Command.C.+CEL" 1%; o! & ne' Command$(2/(" Command.2/" 3%; #elp & ne' Command$(4EL5(" Command.4EL5" 6%; stop & ne' Command$()725(" Command.)725" 8%; exit & ne' Command$(E9I7(" Command.E9I7" :%; item & ne' Command$(I7EM(" Command.I7EM" ;%; < public void start.pp$%{ displa & Displa .=etDispla $t#is%; form.addCommand$screen%; form.addCommand$bac!%; form.addCommand$cancel%; form.addCommand$o!%; form.addCommand$#elp%; form.addCommand$stop%; form.addCommand$exit%; form.addCommand$item%; form.setCommandListener$t#is%; displa .setCurrent$form%; < public void pause.pp$%{< public void destro .pp$boolean destro %{ notif Destro ed$%;
< public void bac!Com$%{ .lert bac! & ne' .lert$(-.C/ Command(" (-ac! Command Executed>(" null" .lert7 pe.I+F2%; bac!.set7imeout$6???%; displa .setCurrent$bac!" form%; < public void o!Com$%{ .lert o! & ne' .lert$(2/ Command(" (2/ Command Executed>(" null" .lert7 pe.I+F2%; o!.set7imeout$6???%; displa .setCurrent$o!" form%; < public void cancelCom$%{ .lert cancel & ne' .lert$(C.+CEL Command(" (Cancel Command Executed>(" null" .lert7 pe.I+F2%; cancel.set7imeout$6???%; displa .setCurrent$cancel" form%; < public void exitCom$%{ .lert exit & ne' .lert$(E9I7 Command(" (Exit Command Executed>(" null" .lert7 pe.I+F2%; exit.set7imeout$6???%; displa .setCurrent$exit" form%; < public void command.ction$Command c" Displa able d% { )trin= label & c.=etLabel$%; if$label.e@uals$(-.C/(%%{ bac!Com$%; < else if$label.e@uals$(2/(%%{ o!Com$%; < else if$label.e@uals$(C.+CEL(%%{ cancelCom$%; < else if$label.e@uals$(E9I7(%%{ exitCom$%; < < <
PhoneBookExample
import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class 5#one-oo!Example extends MIDlet implements CommandListener { private Command exit" next" +e'; private 7ext-ox name" number; private Displa displa ; private )trin= nam" no; private Form form; public 5#one-oo!Example$%{ next & ne' Command$(+ext(" Command.)C*EE+" 0%; exit & ne' Command$(Exit(" Command.)C*EE+" 0%; +e' & ne' Command$(+e'(" Command.)C*EE+" 0%; < public void start.pp$%{ displa & Displa .=etDispla $t#is%; name & ne' 7ext-ox$(Enter +ame(" ((" 1?" 7extField..+A%; name.addCommand$next%; name.setCommandListener$t#is%; number & ne' 7ext-ox$(Enter +umber(" ((" ,1" 7extField.542+E+BM-E*%; number.addCommand$+e'%; number.addCommand$exit%; number.setCommandListener$t#is%; displa .setCurrent$name%; < public void pause.pp$% {< public void destro .pp$boolean unconditional%{ notif Destro ed$%; < public void command.ction$Command c" Displa able s%{ )trin= label & c.=etLabel$%; if $label.e@uals$(Exit(%%{ nam & name.=et)trin=$%; no & number.=et)trin=$%; ) stem.out.println$(+ame & ( C name.=et)trin=$% C (" +umber & (C number.=et)trin=$%%; destro .pp$false%;
< else if $label.e@uals$(+ext(%%{ number.set)trin=$((%; displa .setCurrent$number%; < else if $label.e@uals$(+e'(%%{ displa .setCurrent$name%; nam & name.=et)trin=$%; no & number.=et)trin=$%; ) stem.out.println$(+ame & ( C name.=et)trin=$% C (" +umber & (C number.=et)trin=$%%; name.set)trin=$((%; < < <
LoginExample import javax.microedition.midlet.MIDlet; import javax.microedition.lcdui.*; public class Lo=inExample extends MIDlet implements CommandListener{ private Displa displa ; private 7extField user+ame"pass'ord; public Form form; private Command lo=in"cancel; private Ima=e im=" im=e" im=0; public Lo=inExample$% { form & ne' Form$()i=n in(%; user+ame & ne' 7extField$(Lo=inIDD(" ((" 1?" 7extField..+A%; pass'ord & ne' 7extField$(5ass'ordD(" ((" 1?" 7extField.5.))E2*D%; cancel & ne' Command$(Cancel(" Command.C.+CEL" 0%; lo=in & ne' Command$(Lo=in(" Command.2/" 0%; tr { im= & Ima=e.createIma=e$(Flo=o.pn=(%; im=e & Ima=e.createIma=e$(FfrontGleft,Gbad.pn=(%; im=0 & Ima=e.createIma=e$(FCon=ratulationsH,.pn=(%; <catc#$Exception e%{ ) stem.out.println$e.=etMessa=e$%%; < < public void start.pp$% { displa & Displa .=etDispla $t#is%; tr {form.append$im=%;<catc#$Exception e%{< form.append$user+ame%;
form.append$pass'ord%; form.addCommand$cancel%; form.addCommand$lo=in%; form.setCommandListener$t#is%; displa .setCurrent$form%; < public void pause.pp$% {< public void destro .pp$boolean unconditional% { notif Destro ed$%; < public void validateBser$)trin= name" )trin= pass'ord% { if $name.e@uals$(sandeep(% II pass'ord.e@uals$(sandeep(%% { s#o'Ms=$%; < else { tr .=ain$%; < < public void s#o'Ms=$% { .lert success & ne' .lert$(Lo=in )uccessfull (" (Aour Lo=in 5rocess is completed>(" im=0" .lert7 pe.I+F2%; success.setIma=e$im=0%; user+ame.set)trin=$((%; pass'ord.set)trin=$((%; displa .setCurrent$success" form%; < public void tr .=ain$% { .lert error & ne' .lert$(Lo=in Incorrect(" (5lease tr a=ain(" im=e" .lert7 pe.E**2*%; error.set7imeout$J??%; error.setIma=e$im=e%; user+ame.set)trin=$((%; pass'ord.set)trin=$((%; displa .setCurrent$error" form%; < public void command.ction$Command c" Displa able d% { )trin= label & c.=etLabel$%; if$label.e@uals$(Cancel(%% { destro .pp$true%; < else if$label.e@uals$(Lo=in(%% {