Getting JScrollPane to stop auto-scrolling
I have a JScrollPane (named scrollPane), 2 JPanels (named panel1, panel2), and a JTextArea (named textArea). ScrollPane has panel1 in it while panel1 has a gridBagLayout and it has panel2 and the textArea in it with panel2 being north of textArea. Panel1 is bigger than the screen size so you need to scroll to be able to see all of panel2 and textarea since they fill their constraints.
Now when text is appended to the textarea, no matter where I am currently scrolled with the scrollPane, it scrolls to where the text is added. I have tried the autoscrolls method but that does not work. Setting the caret position of the textArea will not work for how the components are ordered since if I am currently scrolled to panel2, I don't want it to move off of panel2 when text is appened.
Does anyone know of some ways in which to stop the scrollPane from autoscrolling when text is appended to the textArea?