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:

  1. jtable.getcolumnmodel()
  2. tablecolumnmodel
  3. tablecolumnmodel.getcolumn(int)
  4. tablecolumn.setwidth(int) max/min variants.

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -