Adding JTable to empty JScrollPane
Hi All,
Having an issue, where I'm unable to add a table to a scrollpane if the scrollpane is already displayed.
Basically I have a search dialog which has an empty scrollpane, and I want to populate it with a Jtable of results once search is completed.
A snippet (example data, columns):
Code:
String[][] data = {{"aaa"}, {"bbb}};
String[] col = {"col1", "col2"};
DefaultTableModel model = new DefaultTableModel(data,col);
tableView = new JTable(model);
tableScroller.add(tableView); //JScrollPane, already instantiated
tableView.setFillsViewportHeight(true);
I feel like i'm missing something simple....
Thanks!