Table has 4 title but I want to use just 2 of them how can i do that ??
A:
Looking at the How to Use Tables tutorial, I see that you pass an array of data and an array of column names to the JTable constructor. If you only want two columns, these two arrays should reflect that. Here's the example code from the tutorial:
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
Object[][] data = {
{"Mary", "Campione",
"Snowboarding", new Integer(5), new Boolean(false)},
{"Alison", "Huml",
"Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath",
"Knitting", new Integer(2), new Boolean(false)},
{"Sharon", "Zakhour",
"Speed reading", new Integer(20), new Boolean(true)},
{"Philip", "Milne",
"Pool", new Integer(10), new Boolean(false)}
};
JTable table = new JTable(data, columnNames);
So in order to cut back to two columns, the columnNames
array should have only two elements, and the two-dimensional data
array should have only two columns.
Bill the Lizard
2009-11-20 04:44:01
how the heck did you figure out that this was in reference to a JTable?
matt b
2009-11-20 05:28:27
@matt b: It was the only thing I could think of that was close. :)
Bill the Lizard
2009-11-20 12:39:35