How to create dynamic table model in J2ME? like from arrays i use kxml parser to parse my data and show that data in table.
Could you please give me directions? source code is welcome as well!!
my bean looks like this
public class FIDS {
private String FNo;
private String AirCraft;
private String OnDate;
private String Gate;
private String AirCompany;
private String Remark;
private String FTime;
private String BRegTime;
private String ERegTime;
public FIDS(){}
public void SetFN(String fno){this.FNo=fno;}
public String GetFNo(){return this.FNo;}
public void SetAirCraft(String acr){this.AirCraft=acr;}
public String GetAircraft(){return this.AirCraft;}
public void SetOnDate(String d){this.OnDate=d;}
public String GetOnDate(){return this.OnDate;}
public void SetGate(String g){this.Gate=g;}
public String GetGate(){return this.Gate;}
public void SetAirCompany(String ac){this.AirCompany=ac;}
public String GetAirCompany(){return this.AirCompany;}
public void SetRemark(String rem){this.Remark=rem;}
public String GetRemark(){return this.Remark;}
public void SetFTime(String ft){this.FTime=ft;}
public String GetFTime(){return this.FTime;}
public void SetBRegTime(String br){this.BRegTime=br;}
public String GetBRegTime(){return this.BRegTime;}
public void SetERegTime(String er){this.ERegTime=er;}
public String GetERegTime(){return this.ERegTime;}
}
and I'm trying to create an array of objects of my bean and fill it with some data but unable to assign that obj to SimpleTableModel as it's constructor receives String[][] type I'm unable to pass arrObj as the following
FIDS [] fd=new FIDS[5];
for (int i=0;i<5;i++)
{
fd[i].SetFN("SMR23");
fd[i].SetAirCraft("B735");
fd[i].SetAirCompany("Somon Air");
fd[i].SetFTime("10:00");
fd[i].SetGate("A");
}
Object[][] arrObj=new Object[fd.length][4];
TableModel model = new SimpleTableModel(arrObj,new String[]{"Column 1", "Column 2", "Column 3"})
{
public boolean isCellEditable(int row, int col)
{
return false; // return true if editable cell
}
};
for (int index = 0; index < fd.length; index++) {
// model.setValueAt(index, 0, fd[index].GetFNo().toString());// row , column , value
// model.setValueAt(index, 1, fd[index].GetAirCompany().toString());
// model.setValueAt(index, 2, fd[index].GetAirCompany().toString());
}
TableItem table = new TableItem(getDisplay(), "sdfsdf",model);
and also setValue method of TableModel isn't there as I used SimpleTableModel