Creating and Displaying Slides with Text as well as Image
(Experiment 6)
Version 1:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class SlideShowMidlet extends MIDlet implements CommandListener
{
private Display display;
private Command back;
private Command exit;
private Command nxtBtn;
private Form form;
private TextBox txtSlide;
private Form frm;
private Image img, img1;
private ImageItem imgItem, imgItem1;
private StringItem st = new StringItem("","");
public SlideShowMidlet()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.EXIT, 1);
nxtBtn = new Command(">>", Command.OK, 2);
back = new Command("<<", Command.BACK, 3);
/* Code for Creating Screen1 */
form = new Form("Slide Show MIDlet - Home");
String msg = "Hello World!!!!!!!";
form.append(msg);
try {
img = Image.createImage("/MRECW.png");
imgItem = new ImageItem(null,img,ImageItem.LAYOUT_CENTER,"image");
}
catch(Exception e)
{}
form.append(imgItem);
form.addCommand(exit);
form.addCommand(nxtBtn);
form.setCommandListener(this);
/* Code for Creating Screen2 */
txtSlide = new TextBox("Second Screen of Slide Show", "Press Prev Button to go back to Home screen & Next Button to go to Third Screen.", 81, 0);
txtSlide.addCommand(back);
txtSlide.addCommand(nxtBtn);
txtSlide.setCommandListener(this);
/* Code for Creating Screen3 */
frm = new Form("Third Screen of Slide Show");
try {
img1 = Image.createImage("/Future.png");
imgItem1 = new ImageItem(null,img1,ImageItem.LAYOUT_CENTER,"image");
}
catch(Exception e)
{}
frm.append(imgItem1);
frm.addCommand(back);
frm.addCommand(exit);
frm.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{ }
public void destroyApp(boolean unconditional)
{ }
public void commandAction(Command command, Displayable displayable)
{
if (command == back)
{
if (displayable == frm)
{
display.setCurrent(txtSlide);
}
else
{
display.setCurrent(form);;
}
}
else if (command == exit)
{
destroyApp(false);
notifyDestroyed();
}
else if (command == nxtBtn)
{
if (displayable == form)
{
display.setCurrent(txtSlide);
}
else if (displayable == txtSlide)
{
display.setCurrent(frm);
}
}
}
}