java - Put values in JTable, using setModel(); -


i created jtable, using design view - table. but, want values come sql query, not inserted manulally. select on table: model -> custom code, there is: jtable1.setmodel();

what can put there? tried methods return value, netbeans tell me, string cannot converted tablemodel.

i can't modify code initcomponents(), generated netbeans, can put method there.

so how values sql or can use here setmodel() retrieve result sql.

table: 3 columns x 7 lines

the code:

  private void initcomponents() {          jscrollpane1 = new javax.swing.jscrollpane();         jtable1 = new javax.swing.jtable();          setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close);          jtable1.setmodel(resultstable());         jtable1.settooltiptext("");         jscrollpane1.setviewportview(jtable1);  ... more code frame ..... 

you make table model extending abstracttablemodel class , overriding appropriate methods.

take @ https://docs.oracle.com/javase/tutorial/uiswing/components/table.html#data


Comments