import javax.microedition.midlet.MIDlet;
//import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemStateListener;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Displayable;
public class RadioButtons extends MIDlet implements ItemStateListener,CommandListener
{
private Display d;
private Form f;
private Command exit;
private Item it;
private ChoiceGroup rb;
private int n;
private int rn;
public RadioButtons()
{
// d=new Display("");
// d.getDisplay(this);
d=Display.getDisplay(this);
f=new Form("");
rb=new ChoiceGroup("select color", Choice.EXCLUSIVE);
rb.append("Red", null);
rb.append("white",null);
rb.append("Blue",null);
rb.append("Green",null);
//n=rb.append("all",null);//append method returns index no of the optionr
//rb.setSelectedIndex(rn,true);//optional
rb.append("all",null);
exit=new Command("Exit",Command.EXIT,1);
//f=new Form("");
// n=f.append(rb);//omits output is not displayed
f.append(rb);
f.addCommand(exit);
f.setCommandListener(this);
f.setItemStateListener(this);//omits,selected item is not displayed
//d=Display.getDisplay(this);//we can write here also
}
public void startApp()
{
d.setCurrent(f);
}
public void pauseApp()
{
}
public void destroyApp(boolean un)
{
}
public void commandAction(Command c, Displayable dis)
{
if(c==exit)
{
destroyApp(true);
notifyDestroyed();
}
}
public void itemStateChanged(Item i)
{
if(i==rb)
{
StringItem si=new StringItem("selected",rb.getString(rb.getSelectedIndex()));
f.append(si);
}
}
}
//import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemStateListener;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Displayable;
public class RadioButtons extends MIDlet implements ItemStateListener,CommandListener
{
private Display d;
private Form f;
private Command exit;
private Item it;
private ChoiceGroup rb;
private int n;
private int rn;
public RadioButtons()
{
// d=new Display("");
// d.getDisplay(this);
d=Display.getDisplay(this);
f=new Form("");
rb=new ChoiceGroup("select color", Choice.EXCLUSIVE);
rb.append("Red", null);
rb.append("white",null);
rb.append("Blue",null);
rb.append("Green",null);
//n=rb.append("all",null);//append method returns index no of the optionr
//rb.setSelectedIndex(rn,true);//optional
rb.append("all",null);
exit=new Command("Exit",Command.EXIT,1);
//f=new Form("");
// n=f.append(rb);//omits output is not displayed
f.append(rb);
f.addCommand(exit);
f.setCommandListener(this);
f.setItemStateListener(this);//omits,selected item is not displayed
//d=Display.getDisplay(this);//we can write here also
}
public void startApp()
{
d.setCurrent(f);
}
public void pauseApp()
{
}
public void destroyApp(boolean un)
{
}
public void commandAction(Command c, Displayable dis)
{
if(c==exit)
{
destroyApp(true);
notifyDestroyed();
}
}
public void itemStateChanged(Item i)
{
if(i==rb)
{
StringItem si=new StringItem("selected",rb.getString(rb.getSelectedIndex()));
f.append(si);
}
}
}
No comments:
Post a Comment