Java Swing - Multiple column headers in a JTable? -


is there way create multiple column headers in jtable? mean, there 1 row, need 2 of them same format (headerlike), , combine cells of 1 of headers.

i need this:

 header0 |          header123          | header4 header0 | header1 | header2 | header3 | header4 

is there way?

nick meyer kindly reply, while content in address little out of date. run jre 1.7 , didn't works expected can altered work correct. alter made follow

/* * add these code in groupabletableheader */    public void updateui(){ //      setui(this.getui());        tablecellrenderer renderer = getdefaultrenderer();       if (renderer instanceof component) {           swingutilities.updatecomponenttreeui((component)renderer);       }   }  /* * add these code in groupabletableheaderui in 2 places, must know */       if (renderer == null) {           renderer = header.getdefaultrenderer();       }  /* * change getsize method in columngroup  */    public dimension getsize(jtable table) {     component comp = renderer.gettablecellrenderercomponent(         table, getheadervalue(), false, false,-1, -1);     int height = comp.getpreferredsize().height;      int width  = 0;     enumeration en = v.elements();     while (en.hasmoreelements()) {       object obj = en.nextelement();       if (obj instanceof tablecolumn) {         tablecolumn acolumn = (tablecolumn)obj;         width += acolumn.getwidth(); //        width += margin;       } else {         width += ((columngroup)obj).getsize(table).width;       }     }     return new dimension(width, height);   } 

and results. enter image description here


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -