java - How to pass object from table cell editor to Table Model? -


firstly apologize if can not express problem in convenient manner because of little knowledge of java swing.

i have jtable 4 columns. jtable cell editable , hold abstracttablemodel. show dialog box list when first cell going edit mode (i have done well). after choosing data list returns object (i can access object). editor jtextfield display 1 sub value object (i have done also). when cell changes position cell jtable puts value using setvalueat method table model. time returns text hold editor. in fact should return object put object in table model.

i can not understand how can hold object tablecelleditor class , pass setvalueat when jtable automatically trigger put cell value table model? better understanding have mention codes below.

public class myobject {    public string id;    public string name;    public string tag; }   public class my_table_cell_editor extends abstractcelleditor implements tablecelleditor {      private myobject curr_val;      @override     public component gettablecelleditorcomponent(jtable table, object value, boolean isselected, int row, int column) {          component c = table.geteditorcomponent();           if(c==null){             return null;         }          if(column == 0){              mydialog dg = new mydialog(null,true);              dg.setvisible(true);              if("ok".equals(dg.button_state)){                  ((jtextfield)c).settext(dg.return_record.record_name);                  curr_val = dg.return_record;  // return_record myobject                  fireeditingstopped();             }         }                          ((jtextfield)c).selectall();          return c;     }         @override     public object getcelleditorvalue() {         return curr_val;     } }  public class mytablemodel extends abstracttablemodel{  other codes usual...   @override     public void setvalueat(object value, int row, int col) {         rec_model rec = rec_arr.get(row);          switch (col) {             case 0:                 rec.myobj = (myobject) value;                 break;         }                         rec_arr.set(row, rec);         firetablecellupdated(row, col);     } } 

how can hold object from tablecelleditor class , pass to setvalueat() when jtable automatically trigger put cell value table model?

as discussed here, should not: "the table's editingstopped() method collects new value via getcelleditorvalue() , uses setvalueat() in model." there's no need tablecelleditor fireeditingstopped(). aid understanding, found helpful break on editingstopped() in debugger examine call stack.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -