Home | J2ME Yours page | Favorite Links | Contact Me | objques | Canvas Demo | Fruit selection | Commands | Gauge NI | Gauge Response | Pallet | Pal Ex Mid | Slides Text
Prasad's J2ME programs
Quote Slide

Enter subhead content here

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import java.util.*;

public class SlideMid extends MIDlet implements CommandListener{
private Display d;
private Form f1,f2,f3,f4,f5,f6;
private Form[] fc;
private String[] quotes;
private Command cexit;
private Timer tm;
private DownloadTimer tt;

private int nextSlide = 0,maxSlide = 6;
public  SlideMid(){
d =  Display.getDisplay(this);
quotes = new String[6];

quotes[0] = "Opportunity is missed by most people because it is dressed in overalls and looks like work.";
quotes[1] = "Striving for success without hard work is like trying to harvest where you haven't planted.";
quotes[2] = "An investment in knowledge always pays the best interest.";
quotes[3] = "The key is not to prioritize what's on your schedule, but to schedule your priorities.";
quotes[4] = "If I felt it was the right thing to do, I was for it regardless of the possible outcome.";
quotes[5] = "It is the nature of the wise to resist pleasures, but the foolish to be a slave to them.";

f1 = new Form("Slides Testing Form1");
f2 = new Form("Slides Testing Form2");
f3 = new Form("Slides Testing Form3");
f4 = new Form("Slides Testing Form4");
f5 = new Form("Slides Testing Form5");
f6 = new Form("Slides Testing Form6");
fc = new Form[6];
fc[0] = f1;fc[1] = f2;fc[2] = f3;fc[3] = f4;
fc[4] = f5;fc[5] = f6;
cexit = new Command("EXIT",Command.EXIT,1);
f1.append(quotes[0]);
f1.addCommand(cexit);
f1.setCommandListener(this);

f2.append(quotes[1]);
f2.addCommand(cexit);
f2.setCommandListener(this);

f3.append(quotes[2]);
f3.addCommand(cexit);
f3.setCommandListener(this);

f4.append(quotes[3]);
f4.addCommand(cexit);
f4.setCommandListener(this);

f5.append(quotes[4]);
f5.addCommand(cexit);
f5.setCommandListener(this);

f6.append(quotes[5]);
f6.addCommand(cexit);
f6.setCommandListener(this);

}
public void startApp(){
d.setCurrent(f1);
tm = new Timer();
tt = new DownloadTimer();
tm.scheduleAtFixedRate(tt,0,5000);
}

public void pauseApp(){}
public void destroyApp(boolean unconditional){}

public void commandAction(Command c,Displayable s){
if( c == cexit)
tm.cancel();
notifyDestroyed(); 
}

  
private class DownloadTimer extends TimerTask{

public void run(){
d.setCurrent(fc[nextSlide]);
//System.out.println(" "+nextSlide);
nextSlide = (nextSlide+1)%maxSlide;

}
}

}


Enter supporting content here

"Striving for success without hard work is like trying to harvest where you haven't planted."