• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java Swing Question JScrollBar

AFB

Lifer
I have a JText area that I want to scroll down as far as possible when I add text if the user has it scrolled down before the text was added.


So far, I have:


boolean needToScroll = false;
JScrollBar vb = scrollPane.getVerticalScrollBar() ;
vb.setMaximum(100);
System.out.println("Maximum : " +vb.getMaximum() + " Current : " + vb.getValue() );
if(vb.getValue() == vb.getMaximum())
{
needToScroll = true;
}


My problem is that is that getValue() returns a number that is always smaller than getMaximum() even when it's scrolled all the way to the bottom.



Any ideas? 😕




Thanks :beer: :thumbsup:😀
 
the deswcription of setMaximum() says this:

Sets the model's maximum property. Note that the scrollbar's value can only be set to maximum - extent.

you can use getVisibleAmount() to get the extent
 
Originally posted by: dighn
the deswcription of setMaximum() says this:

Sets the model's maximum property. Note that the scrollbar's value can only be set to maximum - extent.

you can use getVisibleAmount() to get the extent

Thatnks 🙂😀 :beer:
 
Back
Top