If a JTable is being displayed in a JScrollPane and the table shows only few rows of data and the rest of table is empty. Changing the color of the empty table space wont work with setBackground(...). To do this
JTable#setFillsViewportHeight(true);
or
JScrollPane#getViewport().setBackground(JTable#getBackground());
or you can to fits JScrollPanes JViewport to the JTables view by
JTable#setPreferredScrollableViewportSize(JTable#getPreferredSize());
This solution is taken from stackoverflow.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment