1 Reply Latest reply: Feb 7, 2012 4:40 AM by 865727 RSS

    How to insert a button in a form in a j2me application ?

    915775
      Dear Friends,
      I'm new to J2ME. I want to know that how to insert a button in a J2ME form. What are the button action listener available here ? Please provide sample code.
        • 1. Re: How to insert a button in a form in a j2me application ?
          865727
          Form form = new Form("Form Title");
          StringItem button = new StringItem("", "Button text", Item.BUTTON);
          Command buttonCommand = new Command("Button command", Command.ITEM, 1);

          button.setDefaultCommand(buttonCommand);
          button.setItemCommandListener(new ItemCommandListener() {
          public void commandAction(Command c, Item item) {
          System.out.println("Button was clicked");
          }
          });
          form.append(button);