You are on page 1of 2

Femin Dharamshi

BE-3/B
Roll no-26

Choice Group Program

Source Code: import javax.microedition.midlet.*; import


javax.microedition.lcdui.*; public class ChoiceGroups extends MIDlet
implements CommandListener
{
Command exit;
public void startApp()
{
Display display = Display.getDisplay(this);
ChoiceGroup books = new ChoiceGroup("Movies : ",
Choice.EXCLUSIVE); books.append("Action", null);
books.append("Romantic", null);
ChoiceGroup vehicles = new ChoiceGroup("Sports : ",
Choice.MULTIPLE); vehicles.append("Cricket", null);
vehicles.append("Football", null);
vehicles.append("Hockey", null); exit = new
Command("Exit", Command.EXIT, 1); Form f = new
Form(""); f.append(books); f.append(vehicles);
f.addCommand(exit);
f.setCommandListener(this); display.setCurrent(f);
}
public void pauseApp(){} public void
destroyApp(boolean unconditional){} public void
commandAction(Command c, Displayable s)
{ if (c == exit)
{
destroyApp(false);
notifyDestroyed();
}
}
}
Femin
Dharamshi
BE-3/B
Output: Roll No.:26

You might also like