I have a TextArea in my Java application and I am adding a lot of lines of text. I need the ScrollPane to scroll to the last add (at the bottom of TextArea). How can i do this?
You can do this by moving the carriage position to the bottom, this will automatically scroll through the TextArea:
textArea.setCaretPosition(textArea.getDocument().getLength());
Scrolling in a text area explains how scrolling works in a bit more detail and provides an alternative solution that could be simpler.
, , , : http://download.oracle.com/javase/tutorial/uiswing/components/scrollpane.html
Amjad Masad , .
: JTextArea (AKA ), , ( ). - . , () Ctrl + , .
JTextArea
You should check if you are on EDT when you call append. If you go beyond the EDT when calling append, JTextArea does not scroll to the last line added (see My post with an example run: scrolling JScrollPane with the last line added ).
Source: https://habr.com/ru/post/1782253/More articles:Iterative MapReduce - pythonGWT serialization and Api add channel - javaCleaning up WinAPI controls - c ++Rails - how to update a single attribute in a controller - ruby-on-railsBluetooth in Java Mobile: Handling Connections Out of Range - javaThe difference between myData as a string, (string) myData and Convert.ToString (myData) - castingScrolling JScrollPane with last line added - javadisable selection of menustrip by pressing alt - .netHow to Open Outlook New Mail Message Window from VB.NET - .netfunction caller name in anonymous function - javascriptAll Articles