Reputation: 3286
In a gui I created I have a JEditorPane that has the following operations during class construction:
htmlPane = new JEditorPane();
htmlPane.setEditable(false);
htmlPane.setContentType("text/html");
htmlPane.setText(Utils.startHtml);
Then during create GUI I do this:
jsp = new JScrollPane( htmlPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
jsp.getViewport().setPreferredSize(new Dimension((width/2)+100,height-85));
rightPanel.add(jsp);
When I load new text into the JEditorPane via set text is scrolls to the botom:
htmlPane.setText(newHtml)
How do I prevent the scrolling to the bottom? I want the top of the html shown.
Upvotes: 1
Views: 129
Reputation: 159844
Try
DefaultCaret caret = (DefaultCaret)htmlPane.getCaret();
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
Upvotes: 2