Advertisement
Guest User

Untitled

a guest
Mar 11th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. import javax.microedition.lcdui.Command;
  2. import javax.microedition.lcdui.CommandListener;
  3. import javax.microedition.lcdui.Display;
  4. import javax.microedition.lcdui.Displayable;
  5. import javax.microedition.lcdui.Form;
  6. import javax.microedition.lcdui.Image;
  7. import javax.microedition.lcdui.ImageItem;
  8. import javax.microedition.midlet.MIDlet;
  9. import javax.microedition.midlet.MIDletStateChangeException;
  10.  
  11. public class MojMidlet2 extends MIDlet implements CommandListener {
  12. private static Display wyswietlacz;
  13. private Command exit;
  14. private Form form;
  15. private Image image;
  16. private ImageItem imageItem;
  17. private Command wprDanych;
  18. private Command przegladDanych;
  19. Form EkranWprDanych;
  20.  
  21. public static Display mojDisplay(){
  22. return wyswietlacz;
  23. }
  24.  
  25.  
  26. public void commandAction ( Command komenda,Displayable elemEkranu){
  27. if (komenda == exit){
  28. try {
  29. destroyApp(false);
  30. } catch (MIDletStateChangeException e) {
  31. e.printStackTrace();
  32. }
  33. notifyDestroyed();
  34. }else if (komenda == wprDanych){
  35. wyswietlacz.setCurrent(EkranWprDanych);
  36. }
  37.  
  38. }
  39. public MojMidlet2() {
  40. try{
  41. image = Image.createImage("/obrazek.png");
  42. }catch(java.io.IOException e){
  43. System.out.println("Problem z czytaniem obrazka");
  44. }
  45. imageItem = new ImageItem("obrazek",image,ImageItem.LAYOUT_DEFAULT,"image");
  46. form = new Form("Menu");
  47. wyswietlacz = wyswietlacz.getDisplay(this);
  48. exit = new Command("Exit",Command.EXIT,1);
  49. wprDanych = new Command("Wpr.Danych",Command.SCREEN,1);
  50. przegladDanych = new Command("Przeg. Danych",Command.ITEM,2);
  51. form.append(imageItem);
  52. form.addCommand(przegladDanych);
  53. form.addCommand(exit);
  54. form.addCommand(wprDanych);
  55. EkranWprDanych = new EkranWprDanych(form);
  56.  
  57. }
  58.  
  59. protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
  60. System.err.println("*** Wywolano destroyApp ***");
  61.  
  62. }
  63.  
  64. protected void pauseApp() {
  65. // TODO Auto-generated method stub
  66.  
  67. }
  68. protected void startApp() throws MIDletStateChangeException {
  69.  
  70. form.setCommandListener((CommandListener)this);
  71. wyswietlacz.setCurrent(form);
  72. }
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement