Skip to content

J2ME GUI Controls – Checkbox

J2ME program for Checkbox
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class CheckExp extends MIDlet implements CommandListener
{
Form form;
Command exit,save;
ChoiceGroup check;
public void startApp()
{
          Display display = Display.getDisplay(this);
          form = new Form(“Check Box Example”);
          try
          {        check  = new ChoiceGroup(“Subjects : “,Choice.MULTIPLE);
                   check.append(“IP”,null);
                   check.append(“ADBMS”,null);
                   check.append(“COM”,null);
          }
          catch(Exception e) 
{e.printStackTrace();}
          form.append(check);
          exit = new Command(“Exit”, Command.EXIT, 1);
          save = new Command(“Save”, Command.OK, 1);
          form.addCommand(save);
          form.addCommand(exit);
          form.setCommandListener(this);
          display.setCurrent(form);
}
  public void pauseApp ()  {}
  public void destroyApp(boolean unconditional)   {} 
  public void commandAction(Command c, Displayable s)
  {
if (c == exit)
          {
                   notifyDestroyed();
}
   }
}
Output:-

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!