Home > Enterprise >  How to stop JScrollPane from automatically updating the Scroll Bar value?
How to stop JScrollPane from automatically updating the Scroll Bar value?

Time:11-05

I use in my app a JscrollPane with a BoxLayout panel inside. I it to never change value after repainting. How can I do this?

I tried pane.getHorizontalScrollBar().setValue() but it doesn't change anything.

CodePudding user response:

You could try setting the Horizontal (and/or) Vertical scrollbar policies:

pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

You could also mess around with the Viewport's size (max & mins), etc.

CodePudding user response:

Found solution. Now I repaint panel inside scrollpane instead of scrollpane and it works.

  •  Tags:  
  • java
  • Related