Guest User

Untitled

a guest
May 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. package piar;
  2.  
  3. import javax.microedition.lcdui.Command;
  4. import javax.microedition.lcdui.CommandListener;
  5. import javax.microedition.lcdui.Display;
  6. import javax.microedition.lcdui.Displayable;
  7. import javax.microedition.lcdui.Form;
  8. import javax.microedition.lcdui.Item;
  9. import javax.microedition.lcdui.StringItem;
  10. import javax.microedition.lcdui.TextField;
  11. import javax.microedition.midlet.MIDlet;
  12. import javax.microedition.midlet.MIDletStateChangeException;
  13.  
  14. public class HelloWorld extends MIDlet implements CommandListener {
  15.  
  16. Form helloForm;
  17. Command exitCommand;
  18. Display display;
  19.  
  20. public HelloWorld() {
  21. }
  22.  
  23. protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
  24. }
  25.  
  26. protected void pauseApp() {
  27. }
  28.  
  29. protected void startApp() throws MIDletStateChangeException {
  30. display = Display.getDisplay(this);
  31.  
  32. // Hello form
  33. helloForm = new Form ("Welcome", new Item[] {
  34. new StringItem("Hello", "Hello world"),
  35. new TextField("Text field", "Enter some text here", 50, TextField.ANY)
  36. });
  37. helloForm.setCommandListener(this);
  38.  
  39. exitCommand = new Command("Exit", Command.EXIT, 0);
  40. helloForm.addCommand(exitCommand);
  41.  
  42. display.setCurrent(helloForm);
  43. }
  44.  
  45. public void commandAction(Command command, Displayable displayable) {
  46. if (command == exitCommand) {
  47. display.setCurrent(null);
  48. notifyDestroyed();
  49. }
  50. }
  51. }
Add Comment
Please, Sign In to add comment