문제

Update : The second solution works perfectly but you have to be careful with the size of some of your object to not active default value for ScrollBar.You can't hide both you have to make a choice ;)

I would like to hide the ScrollBar but still able to scroll on my JScrollPane. I have tried this :

scrollPane.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER);

But i can't scroll anymore :( I have also try this :

scrollPane.getVerticalScrollBar().setPreferredSize (new Dimension(0,0));
scrollPane.getHorizontalScrollBar().setPreferredSize (new Dimension(0,0));
scrollPane.getVerticalScrollBar().setMinimumSize(new Dimension(0, 0));
scrollPane.getVerticalScrollBar().setMinimumSize(new Dimension(0, 0));
scrollPane.getVerticalScrollBar().setMaximumSize(new Dimension(0, 0));
scrollPane.getVerticalScrollBar().setMaximumSize(new Dimension(0, 0));

But still 1 pixel (by default i think) of the ScrollBar still be seen when i scroll :(

도움이 되었습니까?

해결책

I have found the solution :

panLeft.setBackground(new Color(1, 0, 0, 0));
panLeft.setLayout(null);
panLeft.setPreferredSize(null);
panLeft.addMouseWheelListener(new MouseWheelListenerPanLeft());
scrollPaneLeft.setBounds(10, 35, 250, 525);
scrollPaneLeft.setBackground(new Color(1, 0, 0, 0));
scrollPaneLeft.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0));
scrollPaneLeft.getViewport().setBorder(null);
scrollPaneLeft.setViewportBorder(null);
scrollPaneLeft.setBorder(null);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top