Reputation:
I am trying to add a JTable to a JScrollPane. But I can't see the Table after doing this.
scrollpane.setBounds(100,50,800,400);
JTable table = new JTable(myTableModel(res));
scrollpane.add(table);
What's wrong with me?
Upvotes: 2
Views: 191
Reputation: 349
Try this:
JTable table = new JTable(myTableModel(res));
JScrollPane scrollpane = new JScrollPane(table);
scrollpane.setBounds(100,50,800,400);
Upvotes: 0
Reputation: 399
Try this
scrollpane.setBounds(100,50,800,400);
JTable table = new JTable(myTableModel(res));
scrollpane.setViewporView(table);
Upvotes: -1
Reputation: 109813
scrollpane.add(table);
Upvotes: 6