Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Display;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Form;
- import javax.microedition.lcdui.Image;
- import javax.microedition.lcdui.ImageItem;
- import javax.microedition.midlet.MIDlet;
- import javax.microedition.midlet.MIDletStateChangeException;
- public class MojMidlet2 extends MIDlet implements CommandListener {
- private static Display wyswietlacz;
- private Command exit;
- private Form form;
- private Image image;
- private ImageItem imageItem;
- private Command wprDanych;
- private Command przegladDanych;
- Form EkranWprDanych;
- public static Display mojDisplay(){
- return wyswietlacz;
- }
- public void commandAction ( Command komenda,Displayable elemEkranu){
- if (komenda == exit){
- try {
- destroyApp(false);
- } catch (MIDletStateChangeException e) {
- e.printStackTrace();
- }
- notifyDestroyed();
- }else if (komenda == wprDanych){
- wyswietlacz.setCurrent(EkranWprDanych);
- }
- }
- public MojMidlet2() {
- try{
- image = Image.createImage("/obrazek.png");
- }catch(java.io.IOException e){
- System.out.println("Problem z czytaniem obrazka");
- }
- imageItem = new ImageItem("obrazek",image,ImageItem.LAYOUT_DEFAULT,"image");
- form = new Form("Menu");
- wyswietlacz = wyswietlacz.getDisplay(this);
- exit = new Command("Exit",Command.EXIT,1);
- wprDanych = new Command("Wpr.Danych",Command.SCREEN,1);
- przegladDanych = new Command("Przeg. Danych",Command.ITEM,2);
- form.append(imageItem);
- form.addCommand(przegladDanych);
- form.addCommand(exit);
- form.addCommand(wprDanych);
- EkranWprDanych = new EkranWprDanych(form);
- }
- protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
- System.err.println("*** Wywolano destroyApp ***");
- }
- protected void pauseApp() {
- // TODO Auto-generated method stub
- }
- protected void startApp() throws MIDletStateChangeException {
- form.setCommandListener((CommandListener)this);
- wyswietlacz.setCurrent(form);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement