java - How to insert the data from the object into the jTable? -
i have object person
. object in list. want insert data vorname, nachname , alter jtable
.
how can this?
public mainform() { eintragenbutton.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent e) { personlist = personanlegen.personanlegen( textfieldvorname.gettext(), textfieldnachname.gettext(), textfieldalter.gettext() ); string[] spaltenueberschrift = {"vorname", "nachname","alter"}; string[][] inhalt; (int = 0; < personlist.size(); i++) { inhalt[i][i] = personlist.get(0).getvorname(), personlist.get(0).getnachname(), personlist.get(0).getalter(); } tablepersonen = new jtable(); scrollpane.setviewportview(tablepersonen); defaulttablemodel tablemodel = new defaulttablemodel( inhalt, spaltenueberschrift ); tablepersonen.setmodel(tablemodel); } }); }
i have object "person" object in list
basically list
needs part of custom tablemodel
.
you need create custom tablemodel
person
object.
check out row table model step step approach on how can this.
the link shows how make more generic tablemodel
can reuse common code.
Comments
Post a Comment