J2ME Program for RadioButton
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class RadioExp extends MIDlet implements CommandListener
{
Form form;
Command exit;
ChoiceGroup radio;
public void startApp()
{
Display display = Display.getDisplay(this);
form = new Form(“Radio Button Example”);
try
{
radio = new ChoiceGroup(“Gender : “,Choice.EXCLUSIVE);
radio.append(“Male”,null);
radio.append(“Female”,null);
}
catch(Exception e)
{
e.printStackTrace();
}
form.append(radio);
exit = new Command(“Exit”, Command.EXIT, 1);
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:-