java - Maintaining previous position in an EditorPane when the text is refreshed -
this problem has vexed me number of years. user scrolling through text document contained in jeditorpane in turn contained in jscrollpane. user performs function using button changes text (it highlights sections of text). refresh document in jeditorpane reflect highlighting (using html tags). when this, document scrolls top. want document stay in same position user in right before taking action. note, user has not selected text in document can't scroll selection point (that technique work if text selected, alas can't in case). how preserve position in jscrollpane , scroll position user @ prior taking action?
thank you
you can use jviewport.scrollrecttovisible() jump section of document in jscrollpane. can snapshot current position before performing action jviewport.getviewrect()
http://download.oracle.com/javase/6/docs/api/javax/swing/jviewport.html
Comments
Post a Comment