• 0

JTable won't scroll in JScrollPane


Question

I've been having trouble trying to get the table to scroll; it just won't. I've looked some stack answers and tried them, but they aren't working; and I'm not sure if I have something conflicting with those solutions. I just cannot understand what to do from other posts online.

 

I've seen this several times, but I don't know what to do

table.setPreferredScrollableViewportSize(table.getPreferredSize());

my code

tableModel = new TableModel(); //Custom Table Model
table = new JTable();
table.setBorder(null);
table.setFillsViewportHeight(true);
table.setModel(tableModel);

JScrollPane tblScrollPane = new JScrollPane(table);
tblScrollPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
tblScrollPane.setBounds(245, 17, 560, 425);
frmServerAdministration.getContentPane().add(tblScrollPane);
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

This topic is now closed to further replies.