Hello,
I have the following problem, that I try to resolve unsuccessfully
for some time:
I have a JTextPane in a JScrollPane. When I use setText() to update
the text in, the JTextPane gets scrolled to the end (last line).
I'm trying to suppress this - what I need is to have the scroll
bar remaining in the same state as before.
I tried removing all listeners that I could come up with (for example,
the CaretListener), tried extending JTextPane and overwriting the
fireCaretUpdate() method with an empty one - none of this worked.
Any ideas?
Thanks,
- Alex
Vova Reznik - 08 Sep 2005 21:12 GMT
> Hello,
>
[quoted text clipped - 15 lines]
>
> - Alex
if you want to keep scroll in its position
then remeber position, load text, call scrollBar setValue.
setValue should be called from EventQueue
// --- load text --
EventQueue.invokeLater(new Runnable() {
public void run() {
scroll.getVerticalScrollBar().setValue(pos);
}
});
Alexander Avtanski - 08 Sep 2005 21:40 GMT
> [ ... ]
>
[quoted text clipped - 8 lines]
> }
> });
Thanks! It worked perfectly! :-)
- Alex