JTable header question.
I have the following code:
--
MyTableModel mtm = new MyTableModel();
String[] columnNames = {
"Date ",
"Item \n Description ", // <-- This line!!!
"Amount "};
// clear all rows
mtm.setRowCount(0);
mtm.setColumnIdentifiers(columnNames);
--
I would like to display header in two lines.
I added "\n" in to header string..........
I guess it doesn't work that way.
How do I show header in two lines?
Thank you.
[507 byte] By [
tsongweia] at [2007-10-2 10:22:59]

> Does anyone know where can I get some sample code?
You where given sample code.
If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the code retains its original formatting.
[nobr]hello,
hope this help
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
public class table extends JFrame{
public TestDateFormate(){
JTabletable;
JScrollPanetableView;
DefaultTableModeltableModel;
Vector header = new Vector();
Vector data= new Vector();
header.addElement("<html>Item<br>Description</html>");
header.addElement("Reserves");
header.addElement("Amount");
header.addElement("ID");
header.addElement("ReservesRefID");
tableModel = new DefaultTableModel(data, header);
table= new JTable(tableModel);
tableView= new JScrollPane(table);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getTableHeader().setReorderingAllowed(false);
getContentPane().add(tableView);
setVisible(true);
pack();
}
public static void main(String args[]){
new table();
}
}
[/nobr]