Java Phone Number
Java Phone Number
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class TextFielda extends MIDlet implements
CommandListener,ItemStateListener{
private Display display;
private Form form,nform;
private Command exit,next;
private TextField textField;
public TextFielda(){
display=Display.getDisplay(this);
display.setCurrent(form);
}
public void pauseApp(){
}
public void destroyApp(boolean unconditional){
}
public void commandAction(Command command,Displayable displayable){
if(command==next){
display.setCurrent(nform);
}
if(command==exit){
notifyDestroyed();
}
}
public void itemStateChanged(Item item){
if(item==textField){
nform=new Form("result");
exit=new Command("exit",Command.EXIT,0);
if(textField.getString().startsWith("040")||
textField.getString().startsWith("041")||textField.getString().startsWith("050")||
textField.getString().startsWith("0400")||textField.getString().startsWith("044")){
if(textField.size()>=9){
nform.append("valid phone number");
}
}
else{
nform.append("invalid phone number");
}
nform.addCommand(exit);
nform.setCommandListener(this);
}
slideshow
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public SlideShow()
{
display=Display.getDisplay(this);
exit=new Command("EXIT",Command.EXIT,1);
f1.addCommand(exit);
f2.addCommand(exit);
f3.addCommand(exit);
f1.setCommandListener(this);
f2.setCommandListener(this);
f3.setCommandListener(this);
}
public void startApp()
{
Thread runner=new Thread(new ThreadRunner(display,f1,f2,f3));
runner.start();
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c,Displayable display){
if(c==exit)
{
destroyApp(true);
notifyDestroyed();
}
}
class ThreadRunner implements Runnable{
Display display;
int c=0;
Form f1,f2,f3;
public ThreadRunner(Display display,Form f1,Form f2,Form f3){
this.display=display;
this.f1=f1;
this.f2=f2;
this.f3=f3;
}
public void run(){
while(true){
c++;
if(c==1)
display.setCurrent(f1);
else if(c==2)
display.setCurrent(f2);
else if(c==3)
display.setCurrent(f3);
else if(c==4)
c=0;
try{
Thread.sleep(1500);
}
catch(Exception e){
}
}
}
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
{
display=Display.getDisplay(this);
exit=new Command("EXIT",Command.EXIT,1);
try{
i1=Image.createImage("/index1.png");
i2=Image.createImage("/index2.png");
i3=Image.createImage("/index3.png");
it1=new ImageItem("p1",i1,ImageItem.LAYOUT_DEFAULT,"unable");
it2=new ImageItem("p2",i2,ImageItem.LAYOUT_DEFAULT,"unable");
it3=new ImageItem("p3",i3,ImageItem.LAYOUT_DEFAULT,"unable");
f1=new Form("first form");
f1.append(i1);
f1.addCommand(exit);
f2.addCommand(exit);
f3.addCommand(exit);
f1.setCommandListener(this);
f2.setCommandListener(this);
f3.setCommandListener(this);}
catch(java.io.IOException error){
Alert alert=new Alert("error","cannot find",null,null);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
} }
public void startApp()
{
Thread runner=new Thread(new ThreadRunner(display,f1,f2,f3));
runner.start();
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c,Displayable display){
if(c==exit)
{
destroyApp(true);
notifyDestroyed();
}
}
class ThreadRunner implements Runnable{
Display display;
int c=0;
Form f1,f2,f3;
public ThreadRunner(Display display,Form f1,Form f2,Form f3){
this.display=display;
this.f1=f1;
this.f2=f2;
this.f3=f3;
}
public void run(){
while(true){
c++;
if(c==1)
display.setCurrent(f1);
else if(c==2)
display.setCurrent(f2);
else if(c==3)
display.setCurrent(f3);
else if(c==4)
c=0;
try{
Thread.sleep(1500);
}
catch(Exception e){
}
}
}
}
}