// This example is Multiple choice check boxes import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class MultipleChoice extends MIDlet implements ItemStateListener, CommandListener{ private Display display; // a display private Form fmMain; // main form private Command cmExit; // exit command private Command cmView; // view command to view the slected items private int selectIndex; // Index of the select all option private ChoiceGroup cgPrefer; // choice group of prefernces private int choiceGroupIndex; // index of the choice group // contructor public MultipleChoice(){ display = Display.getDisplay(this); // get diplay // Create a multiple choice group cgPrefer = new ChoiceGroup("Preferences", Choice.MULTIPLE); // Append options without any images cgPrefer.append("Auto Indent", null);// append an Auto Indent option cgPrefer.append("Replace Tab", null); // append a Replace Tab option cgPrefer.append("Wrap Text", null); //append Wrap Text option selectIndex = cgPrefer.append("Select All", null); // append Select All option // set Auto indent as default choice cgPrefer.setSelectedIndex(selectIndex, true); // create commands cmExit = new Command("Exit", Command.EXIT, 1); cmView = new Command("View", Command.SCREEN, 2); // create Form, add commands and listen for events fmMain = new Form(" "); // a form with no title choiceGroupIndex = fmMain.append(cgPrefer); fmMain.addCommand(cmExit); fmMain.addCommand(cmView); fmMain.setCommandListener(this); fmMain.setItemStateListener(this); } // start App public void startApp(){ display.setCurrent(fmMain); } // pause App public void pauseApp(){ } // destroy App public void destroyApp(boolean unconditional){ } public void commandAction(Command c, Displayable s){ if(c == cmView){ boolean selected[] = new boolean[cgPrefer.size()]; // examine and see whether any option is selected cgPrefer.getSelectedFlags(selected); for (int i = 0; i