Domanda

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 :(

È stato utile?

Soluzione

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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top