java - Auto-update JTable that is populated using a List<T> -


the program allow user make search. search result shown in jtable. user can select row , hit button called "edit" editing on "item".

once info edited , hits ok, jtable not being updated.

table before editing:

http://i.stack.imgur.com/unrtk.jpg

user clicks on button "edit" , edits last field jtable still showing old info, it's not being updated

http://i.stack.imgur.com/qmxd8.jpg

here's code:

public void paneltable(){     paneltable = new jpanel()     paneltable.setsize(400, 80);     paneltable.setopaque(true);     table =  new jtable();     modele  = new defaulttablemodel(); }  public string getdata(int colonnb ,int index){      string datatab = data[colonnb][index] + "";      return datatab; }   public void creerjtable(list<pneu> liste){     string[] head= {"a", "b", "c"};     this.liste = liste;       data = new object[liste.size()][3];     iterator<pneu> = liste.iterator();     int index = 0;      while(it.hasnext()){         pneu unpneu = it.next();         data[index][0] = unpneu.construiredecription();         data[index][1] = unpneu.getprix();         data[index][2] = unpneu.getnombrepneus();         index++;     }       modele.setdatavector(data, head);     table.setmodel(modele);     table.setrowselectioninterval(0, 0);     componentscroll(data,head);      nbsearch++; }   public void componentscroll(object[][] data, string[] head){     if(nbsearch <= 0){         table.setselectionmode(listselectionmodel.single_selection);         table.setfillsviewportheight(true);         table.setpreferredscrollableviewportsize(new dimension(500, 80));         table.setmodel(modelecolonnesnoedit(data, head));          table.setrowselectioninterval(0, 0);         table.getcolumnmodel().getcolumn(0).setpreferredwidth(250);         table.getcolumnmodel().getcolumn(1).setresizable(false);         table.getcolumnmodel().getcolumn(1).setpreferredwidth(50);         table.getcolumnmodel().getcolumn(2).setresizable(false);         table.getcolumnmodel().getcolumn(2).setpreferredwidth(50);          jscrollpane scrollpane = new jscrollpane(table);         scrollpane.setpreferredsize(new dimension(500, 60));          panotab.add(scrollpane);     }    }  private defaulttablemodel modelecolonnesnoedit(object[][] data, string[] head) {      return new defaulttablemodel(data, head)     {          boolean[] columneditables = new boolean[] { false, false, false};          public boolean iscelleditable(int row, int column) {             return columneditables[column];         }     }; } 

i fixed calling again method creerjtable , passing new list !

it 1 line of code : creerjtable(uneliste);

thank effort guys!


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -