By Alvin Alexander. Last updated: June 6, 2016
If you want the horizontal and/or vertical scrollbars to always show on a Java JScrollPane, configure them like this:
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
Other options are:
HORIZONTAL_SCROLLBAR_AS_NEEDED HORIZONTAL_SCROLLBAR_NEVER
and:
VERTICAL_SCROLLBAR_AS_NEEDED VERTICAL_SCROLLBAR_NEVER
See the ScrollPaneConstants Javadoc for more information.