I am using a JScrollPane which contains inside it a JTextArea. The problem is when the JTextArea is populated with a lot of text, the JScrollPane automatically scrolls down. What property should I set on the JScrollPane to avoid this automatic scrolling down? Thanks.
I am using a JScrollPane which contains inside it a JTextArea . The problem
Share
If the JScrollPane is decorating a text component, it will automatically scroll to the bottom, but after it loads calling setCaretPosition(0) on your text component will cause it to scroll to the top.
However, if it’s not a text component, you can also alter the viewport like this: