Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Jtable not showing column Names

843806Nov 4 2008 — edited Nov 4 2008
I wrote the following Code and strangely it isn't showing the column Names....
The mistake should be foolish..but i can't figure it out...

can you please help.. or give any alternate way to do the same
import javax.swing.*;
import javax.swing.table.*;
public class test
{
	public static String[] columnNames = {"User Name","User ID"};
	public static void main(String args[])
	{
		JFrame frame = new JFrame();
		frame.setSize(400, 400);
		DefaultTableModel tabmodel = new DefaultTableModel(columnNames, 15);
		JTable table = new JTable(tabmodel);
		frame.add(table);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 2 2008
Added on Nov 4 2008
2 comments
246 views