How to create a dynamic table model in J2ME? as from arrays I use the kxml parser to parse my data and display that data in a table.
Could you give me directions? source code is also welcome!
my bean is as follows
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 my bean objects and fill it with some data, but I canβt assign this object to SimpleTableModel, because it gets the type String [] [] I can not pass arrObj as follows
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);
as well as the setValue method for TableModel does not exist since I used SimpleTableModel
source share