java - Auto/manually set column width JTable with db data -
in code havejtable
filled data database.
this constructor of jpanel:
public mainpanel(vector<vector<string>> films) { dimension dim = toolkit.getdefaulttoolkit().getscreensize(); int width = this.getsize().width; int height = this.getsize().height; int x = (dim.width-width)/2; int y = (dim.height-height)/2; header = new vector<string>(); data = new vector<vector<string>>(); header.add("id"); header.add("name"); header.add("year"); header.add("genre"); this.data = films; this.setvisible(true); this.setlocation(x, y); initcomponents(); }
and initialize of jtable
:
jtable2 = new javax.swing.jtable(); setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close); jtable2.setmodel(new javax.swing.table.defaulttablemodel( data, header )); tablecolumnmodel tcm; tcm = jtable2.getcolumnmodel(); (int = 0; < header.size(); i++) { tablecolumn tc; tc = tcm.getcolumn(i); tc.setwidth(2); }
can me why isn't width 2 , same still?
thanks response.
look into:
Comments
Post a Comment