I drag jtabel from palette and i try to customize the code for multi-line header but in table it's not showed.sorry for my ugly English. thanks in advance
jTable1=new javax.swing.JTable();
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane4.setViewportView(jTable1);
jTable1.getColumnModel().getColumn(0).setHeaderValue("poa\nsfh");
The default renderers in Swing use a JLabel to render the text. A JLabel doesn't not recognize the "\n" String.
A JLabel can display HTML, so you can try using HTML for the heading. Read the section from the Swing tutorial on How to Use HTML in Swing Components for more information.