Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Based on Code from Code-Guru:</p> <pre><code>/* * (swing1.1beta3) * * |-----------------------------------------------------| * | 1st | 2nd | 3rd | * |-----------------------------------------------------| * | | | | | | | */ //package jp.gr.java_conf.tame.swing.examples; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; import jp.gr.java_conf.tame.swing.table.*; /** * @version 1.0 11/09/98 */ public class MultiWidthHeaderExample extends JFrame { MultiWidthHeaderExample() { super( "Multi-Width Header Example" ); DefaultTableModel dm = new DefaultTableModel(); dm.setDataVector(new Object[][]{ {"a","b","c","d","e","f"}, {"A","B","C","D","E","F"}}, new Object[]{"1 st","","","","",""}); JTable table = new JTable( dm ) { protected JTableHeader createDefaultTableHeader() { return new GroupableTableHeader(columnModel); } }; TableColumnModel cm = table.getColumnModel(); ColumnGroup g_2nd = new ColumnGroup("2 nd"); g_2nd.add(cm.getColumn(1)); g_2nd.add(cm.getColumn(2)); ColumnGroup g_3rd = new ColumnGroup("3 rd"); g_3rd.add(cm.getColumn(3)); g_3rd.add(cm.getColumn(4)); g_3rd.add(cm.getColumn(5)); GroupableTableHeader header = (GroupableTableHeader)table.getTableHeader(); header.addColumnGroup(g_2nd); header.addColumnGroup(g_3rd); JScrollPane scroll = new JScrollPane( table ); getContentPane().add( scroll ); setSize( 400, 100 ); header.revalidate(); } public static void main(String[] args) { MultiWidthHeaderExample frame = new MultiWidthHeaderExample(); frame.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { System.exit(0); } }); frame.setVisible(true); } } </code></pre> <p>Source: <a href="http://www.codeguru.com/java/articles/125.shtml" rel="nofollow">http://www.codeguru.com/java/articles/125.shtml</a> (unavailable since 2012, see now in <a href="https://web.archive.org/web/20111201210527/http://www.codeguru.com/java/articles/125.shtml%20web-archive" rel="nofollow">web archive</a>)</p> <p>Other ressources:</p> <ul> <li>Java-6 updated sources: <a href="http://qoofast.blog76.fc2.com/blog-entry-2.html" rel="nofollow">http://qoofast.blog76.fc2.com/blog-entry-2.html</a> <a href="http://translate.google.ch/translate?hl=de&amp;sl=ja&amp;tl=en&amp;u=http%3A%2F%2Fqoofast.blog76.fc2.com%2Fblog-entry-2.html&amp;anno=2" rel="nofollow">(translated)</a> <ul> <li><a href="http://blog-imgs-46.fc2.com/q/o/o/qoofast/ColumnGroup.txt" rel="nofollow">ColumnGroup.java</a> </li> <li><a href="http://blog-imgs-46.fc2.com/q/o/o/qoofast/GroupableTableHeader.txt" rel="nofollow">GroupableTableHeader.java</a> </li> <li><a href="http://blog-imgs-46.fc2.com/q/o/o/qoofast/GroupableTableHeaderUI.txt" rel="nofollow">GroupableTableHeaderUI</a></li> </ul></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload