java - JTable , Celleditor , how do i startCellEditing? -


i have jtable , couple of cells rows ( 1 column ) have textboxes on double clicking particular cell , user can edit cell have separate edit button part of application editing cells since there no "startcellediting" method on getting getcelleditor (only stopcellediting there )

if call editcellat(row,column) method (on clicking edit button ) removing existing content , user has enter entire content again .

how behavior ? inshort , instead of user double clicking cell edit , clicks on edit button , how achieve same behavior ?

this code not clears cell content on button click

import javax.swing.*; import javax.swing.table.defaulttablemodel; import java.awt.*; import java.awt.event.actionevent; import java.awt.event.actionlistener;  public class test extends jframe {      public test() {          defaulttablemodel tablemodel = new defaulttablemodel();         tablemodel.setrowcount(2);         tablemodel.setcolumncount(2);         tablemodel.setvalueat("foo", 0, 0);         final jtable t = new jtable(tablemodel);          jpanel comp = new jpanel(new borderlayout());         getcontentpane().add(comp);          comp.add(t, borderlayout.center);         jbutton edit = new jbutton("edit");         edit.addactionlistener(new actionlistener() {             public void actionperformed(actionevent e) {                 t.editcellat(0, 0);             }         });         comp.add(edit, borderlayout.south);          pack();         setvisible(true);      }      public static void main(string[] args) {         new test();     } } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -