Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide the JScrollBars in a JScrollPane

Tags:

java

swing

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?

like image 274
farm ostrich Avatar asked Apr 08 '11 03:04

farm ostrich


People also ask

How do you make JScrollPane invisible?

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 JScrollPane and scrollbar?

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.


2 Answers

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);
like image 70
parth chandarana Avatar answered Oct 10 '22 21:10

parth chandarana


scrollpane.setHorizontalScrollBarPolicy(...) 
scrollpane.setVerticalScrollBarPolicy(...) 
like image 28
camickr Avatar answered Oct 10 '22 20:10

camickr