SIVAKUMAR
New user

Posts: 8
|
HERE IS MY CODING:
import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.TextBox; import javax.microedition.lcdui.TextField; import javax.microedition.midlet.*; import org.netbeans.microedition.lcdui.SimpleTableModel; import org.netbeans.microedition.lcdui.TableItem;
public class Midlet4SimpleTable extends MIDlet implements CommandListener{ Form frm; TableItem table_item; SimpleTableModel model1; String table_str[][]; Display display; TextBox txtbox; Command edit,ok; int sel_row,sel_col; public void startApp() { display.setCurrent(frm); }
public void pauseApp() { }
public void destroyApp(boolean unconditional) { }
public Midlet4SimpleTable() { edit=new Command("Edit",Command.OK,0); ok=new Command("Ok",Command.OK,0); display=Display.getDisplay(this); frm=new Form("\n\tDemo of simple table"); table_str=new String[3][3]; for(int i=0;i<3;i++) { for(int j=0;j<3;j++) table_str[i][j]=new String(""+i+","+j); } String col[]=new String[]{"col1","col2","col3"}; table_item=new TableItem(display,"Table1"); model1=new SimpleTableModel(table_str,col); table_item.setModel(model1); frm.append(table_item); frm.addCommand(edit); frm.setCommandListener(this); txtbox=new TextBox("Editing",null,1000,TextField.ANY); txtbox.addCommand(ok); txtbox.setCommandListener(this); }
public void commandAction(Command c, Displayable d) { //throw new UnsupportedOperationException("Not supported yet."); if(c==edit) { sel_row=table_item.getSelectedCellRow(); sel_col=table_item.getSelectedCellColumn(); txtbox.setString(null); display.setCurrent(txtbox); } else { model1.setValue(sel_col, sel_row,(new String(txtbox.getString()))); model1.fireTableModelChanged(); display.setCurrent(frm); } } }
PROBLEM: if user selectg an cell then click edit means then the textbox is appears.After entering data in text box then user clicks ok then the modified content is placed in a appropriate cell in a table.All are working correctly. But here problem is after modifying cell value i need to show the particular cell is highlighted.There is no such function in TableITem and SimpleTableModel.so tell me how do i achieve it.
|