Hello comus and welcome to the Ranch! The code snippet does not provide enough information for a definitive answer. To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.
Are the scroll pane and its content realized at the time you call getMaximum()?
luck, db
There are no new questions, but there may be new answers.