Skip to content

Commit 1cecc6c

Browse files
committed
SwingTextDisplayPanel: keep scroll pane at the top
After adding a bunch of text, the text pane's default behavior is to scroll the caret position to the bottom. It is nicer for readability to start at the top, so let's reset the caret position after adding text each time.
1 parent ddf9946 commit 1cecc6c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/main/java/org/scijava/ui/swing/viewer/text/SwingTextDisplayPanel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public void redraw() {
134134
final boolean html = text.startsWith("<html>");
135135
textArea.setContentType(html ? "text/html" : "text/plain");
136136
textArea.setText(text);
137+
textArea.setCaretPosition(0);
137138
}
138139

139140
// -- HyperlinkListener methods --

0 commit comments

Comments
 (0)