Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1228
| From | "phengtang" <phengtang@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Solution found |
| Message-ID | <1174311406.936143.15800@e1g2000hsg.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <PxUHh.11471$qj1.9654@reader1.news.saunalahti.fi> |
| Date | 2011-04-27 15:32 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
On Mar 8, 2:51 pm, loquak <plz.re...@to.ng> wrote:
> loquak kirjoitti:
>
>
>
>
>
> > Hi.
> > I'm trying to apply a feature where the dialog (containing one
> > JTextPane) remembers the last vertical scroll position of the pane. When
> > the dialog is re-opened, the pane will automatically be scrolled down to
> > the position where it was before closing the dialog.
>
> > Logically, I thought the following would do the trick:
>
> > On close:
> > lastPos.pos = scrollPane.getViewport().getViewPosition(); (lastPos.pos =
> > Point)
>
> > On re-open:
> > scrollPane.getViewport().setViewPosition(new Point(0,0));
>
> > Didn't work, so I tried the following:
>
> > On close:
> > lastPos.pos = scrollPane.getVerticalScrollBar().getValue(); (lastPos.pos
> > = int)
>
> > On re-open:
> > scrollPane.getVerticalScrollBar().setValue(lastPos.pos);
>
> > Didn't work either! So, logically again, I'm out of ideas. Any tips? (I
> > have no use for setCaretPosition and getCaretPosition since the caret
> > won't be used, as the pane is read-only)
>
> SwingUtilities.invokeLater(new Runnable()
> {
> public void run()
> {
> scrollPane.getVerticalScrollBar().setValue(lastPos.pos);
> }
> });
>
> did the trick!- Hide quoted text -
>
> - Show quoted text -
I have the same pb, and the work-around SwingUtilities.invokeLater
works fine, Thanks.
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Find similar | Unroll thread
Scrolling JTextPane insid "loquak" <loquak@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Sorry, typo "loquak" <loquak@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Solution found "loquak" <loquak@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: Solution found "phengtang" <phengtang@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
csiph-web