I can't seem to find an answer to this on stackoverflow or at the javadoc site. It's probably very trivial. Could someone help?
You need to use setOpaque(false) to make it transparent. Call that both on the JScrollPane, and on it's ViewPort. sp. setOpaque(false); sp.
What is the difference between a Scrollbar and a JScrollPane ? A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs its own scrolling.
I think with setHorizontalScrollBarpolicy() you can set scrollbar apperance means when you want to display your scrollbar like JScrollPane.VERTICAL_SCROLLBAR_ALWAYS displays vertical scrollbar always and so on.. This may help you.
JScrollPane jsp = new JScrollPane(lista);
jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollpane.setHorizontalScrollBarPolicy(...)
scrollpane.setVerticalScrollBarPolicy(...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With