I want to print only selected rows in a JTable. My approach is to make a new TableModel, copy the selected rows there, add the tableModel to a new JTable and then print this new Table. My Problem: It doesnt work as expected, I just see a black line with the height of the rows, if i select lesser rows the line is smaller) but no content. But the content is in the table model, i can see it when i do system.out... this is my code:
QueryTableModel tempModel = new QueryTableModel(String[] tableheaders);
JTable tempTable = new JTable();
for(int i : table.getSelectedRows())
tempModel.addRow(((QueryTableModel)table.getModel()).getRowAt(i));
System.out.println(tempModel.getRowCount());
tempTable.setModel(tempModel);
tempTable.print(JTable.PrintMode.FIT_WIDTH, header, null);