import java.io.IOException; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class LCDui2 extends MIDlet implements CommandListener { private Display display; private Form form; private Image image; private Command next; private Command back; private int slideNum; private int maxSlideNum=5; public void startApp() { display = Display.getDisplay(this); form = new Form(null); form.setCommandListener(this); next = new Command("Next", Command.OK, 1); form.addCommand(next); back = new Command("Back", Command.BACK, 1); form.addCommand(back); Ticker t = new Ticker("Photoalbum"); form.setTicker(t); setImage("/1.png"); display.setCurrent(form); } public void commandAction(Command c, Displayable d) { if (c == next && slideNum < maxSlideNum) slideNum++; if (c == back && slideNum > 1) slideNum--; form.delete(0); setImage("/"+Integer.toString(slideNum)+".png"); } public void setImage(String path) { try { image = Image.createImage(path); } catch (IOException ioe) { System.out.println(ioe.getMessage()); form.append(image); } } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }