I have some troubles with adding JScrollPane
to JTable
in my application. There are two classes: Controller
and Main
form.
In Main
form the table is initialized as private variable, and in Controller I'm getting it using getter. Now I have such code in Controller
to create and update table using TableModel
:
private void updateTables(String[][] distanceMatrixData, String[] columnNames) {
TableModel distanceMatrixModel = new DefaultTableModel(distanceMatrixData, columnNames);
mainForm.getDistanceMatrix().setModel(distanceMatrixModel);
}
I don't have idea how to implement JScrollPane
to this code because I don't create the table object.