0

When i create a JTable like the code shown below:

[B]String[] columnNames = {"First Name",
                                "Last Name",
                                "Sport",
                                "# of Years"};

        Object[][] data = {
            {"", "",
              new Integer(5),""},
            {"", "",
              new Integer(5),""},
            {"", "",
              new Integer(5),""},
{"", "",
              new Integer(5),""},
           {"", "",
              new Integer(5),""},
        };
 

     	JTable table=new JTable(data,columnNames);
	table.doLayout() ;[/B]

jp2.add(table);//where jp2 is a panel on a container on a frame

I dont get the Column names of the TABLE ..
The Table Screenshot i m presenting in the attachments

Please Help me with how to get Column names Displayed in the Table when the program is run

Attachments have screenshots of program when run..

Attachments Full_Frame.JPG 51.78 KB Table_with_no_column_names.JPG 16.99 KB
3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Ezzaral
0

This line from the JTable API explains your issue

Note that if you wish to use a JTable in a standalone view (outside of a JScrollPane) and want the header displayed, you can get it using getTableHeader() and display it separately.

. You probably want a scroll pane anyway if the number of rows can exceed your view area.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.