I have created an application in J2ME in which i have created a form and appended multiple text fields using Itemstatelistener method.The scenario is I have used Name,Age,DOB,Income fields in which i am INSERTING an Income field on any entry in Age field by using Itemstatechanged(). The problem i am facing here is whenever i enter Age,Income field gets inserted after DOB field and then when i try to enter in DOB field the value of DOB is getting entered in Income field.The focus shifts to Income field whenever i try to enter DOB. Its a device specific problem i.e its happening only SAMSUNG phone devices.
public Form getInput_form() {
if (input_form == null) {
input_form = new Form("", new Item[]{getTxtName(), getTxtAge(), getDOB()})
input_form.addCommand(getCmdBACK());
input_form.addCommand(getInput_Ok());
input_form.setCommandListener(this);
input_form.setItemStateListener(this);
}
return input_form;
}
public void itemStateChanged(Item item)
{
if(item.equals(txtAge))
{
if(!(txtAge.getString().equals("")))
{
if(Integer.parseInt(txtAge.getString()) > 18)
{
if(txtIncome ==null)
{
txtIncome = new TextField("DAB SUM",getIncomeSum(), 8, TextField.NUMERIC);
input_form.set(3,txtIncome);
}
}
}
}
}
Here is the code and above i have explained my query.

Reply With Quote

