Results 1 to 3 of 3
Thread: DefaultTableModel problem
- 10-31-2009, 04:11 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 4
- Rep Power
- 0
DefaultTableModel problem
hello guys.. I m trying to create a graphic table useing the class DefaultTableModel.
So, the problem is that it does not print the title of each column.
For example, i want to print in the window the following :
ID Title
1 lol
2 lala
the following code prints only
1 lol
2 lala
without the titles..
Please! need help!Java Code:JFrame frame = new JFrame("Select Registration"); JPanel panel = new JPanel(); //String types[]= {"id", "title", "username","password","url","notes"}; String data[][] = { {"132","facebook"}}; // String col[] = {"Name","code"}; String types[] = {"id","title"}; /* Vector types =new Vector() ; types.add("id"); types.add("title"); types.add("username"); types.add("password"); types.add("url"); types.add("notes"); */ DefaultTableModel model = new DefaultTableModel(data,types); JTable table = new JTable(model); panel.add(table); frame.add(panel); //frame.setSize(300, 300); frame.setVisible(true); frame.setResizable(true);
thnx :)Last edited by stylian; 10-31-2009 at 04:21 PM.
- 10-31-2009, 04:16 PM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Edit your posting and use the "Code" tags on your code so the code retains its formatting properly. Its good practice for your next question.
should be:Java Code:panel.add(table); frame.add(panel);
Java Code:JScrollPane scrollPane = new JScrollPane(table); frame.add(scrollPane);
- 10-31-2009, 04:23 PM #3
Member
- Join Date
- Oct 2009
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
RequestFocus on DefaultTableModel Particular Cell
By yernikumar in forum AWT / SwingReplies: 1Last Post: 03-01-2009, 04:58 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks