M
mehafi
Hi,
Does someone know why headers of this table doesn't appears?
import java.awt.*;
import javax.swing.*;
public class TestTable {
public static void main(String[] argum) {
String[] Headers = new String[] {"Number", "New?", "Origin",
"Destination", "Produced", "Weight" };
Object[][] Data = new Object[][]
{
{ "100420", Boolean.FALSE, "Des Moines IA", "Spokane WA",
"02/06/2000", new Float(450) },
{ "202174", Boolean.TRUE, "Basking Ridge NJ", "Princeton NJ",
"05/20/2000", new Float(1250) },
{ "450877", Boolean.TRUE, "St. Paul MN", "Austin TX",
"03/20/2000",
new Float(1745) },
{ "101891", Boolean.FALSE, "Boston MA", "Albany NY",
"04/04/2000", new
Float(88) }
};
JTable Tab = new JTable(Data, Headers);
JFrame Frame = new JFrame("TestTable");
Frame.getContentPane().add( Tab );
Frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
Frame.setSize(500, 200);
Frame.setVisible(true);
}
}
Interesting, that when I put this table into JScrollPane, headers
appears:
Frame.getContentPane().add( new JScrollPane( Tab ) );
But it doesn't works in simple JPanel. Is it necesary putting table
into
JScrollPane?
thanks in advane
Does someone know why headers of this table doesn't appears?
import java.awt.*;
import javax.swing.*;
public class TestTable {
public static void main(String[] argum) {
String[] Headers = new String[] {"Number", "New?", "Origin",
"Destination", "Produced", "Weight" };
Object[][] Data = new Object[][]
{
{ "100420", Boolean.FALSE, "Des Moines IA", "Spokane WA",
"02/06/2000", new Float(450) },
{ "202174", Boolean.TRUE, "Basking Ridge NJ", "Princeton NJ",
"05/20/2000", new Float(1250) },
{ "450877", Boolean.TRUE, "St. Paul MN", "Austin TX",
"03/20/2000",
new Float(1745) },
{ "101891", Boolean.FALSE, "Boston MA", "Albany NY",
"04/04/2000", new
Float(88) }
};
JTable Tab = new JTable(Data, Headers);
JFrame Frame = new JFrame("TestTable");
Frame.getContentPane().add( Tab );
Frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
Frame.setSize(500, 200);
Frame.setVisible(true);
}
}
Interesting, that when I put this table into JScrollPane, headers
appears:
Frame.getContentPane().add( new JScrollPane( Tab ) );
But it doesn't works in simple JPanel. Is it necesary putting table
into
JScrollPane?
thanks in advane