Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #4698
| From | "John B. Matthews" <nospam@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.java.gui |
| Subject | Re: fighting over the scroller |
| Date | 2011-09-22 13:41 -0400 |
| Organization | The Wasteland |
| Message-ID | <nospam-B769B2.13413722092011@news.aioe.org> (permalink) |
| References | <ucsh77pf9v4eoo7o8jjjoqrdt4ptjpg4fm@4ax.com> <nospam-30920C.19151020092011@news.aioe.org> <1c0j779arr138ua3kr50ed1ju8u5jm0of3@4ax.com> |
In article <1c0j779arr138ua3kr50ed1ju8u5jm0of3@4ax.com>,
Roedy Green <see_website@mindprod.com.invalid> wrote:
> On Tue, 20 Sep 2011 19:15:10 -0400, "John B. Matthews"
> <nospam@nospam.invalid> wrote, quoted or indirectly quoted someone who
> said :
>
> >This example highlights the effect. While it's easy to demonstrate
> >contention, say by simultaneously gesturing with the mouse and
> >holding down an arrow key, correct use of the EDT keeps events
> >well-ordered.
> >
> ><http://stackoverflow.com/questions/7201509>
> >
> >Is this a problem in practice?
>
> The practical problem I notice is at
> http://mindprod.com/applet/vercheck.html
>
> Vercheck displays a scrollable table. You can ask it to update each
> row of the table by probing the corresponding web site in turn. As
> it goes it scrolls the table to keep the item it is working on in
> view.
>
> However, sometimes you want to override this behaviour to take a look
> at something off screen. You scroll, but the program immediately
> yanks you away. I would like it to suppress programmatic scrolling
> for X seconds since if you scrolled, presumably you are looking at
> something and don't want it scrolled offscreen.
I see. Text components [1] have a DefaultCaret [2], which maintains an
UpdatePolicy property that's useful in this context. In contrast, you
have to manage it yourself for JTable.
I typically establish a suitable attribute:
private boolean isAutoScroll;
And scroll accordingly:
if (isAutoScroll) {
Rectangle r = table.getCellRect(...);
table.scrollRectToVisible(r);
}
One convenient approach is to condition the property in an
AdjustmentListener:
public void adjustmentValueChanged(AdjustmentEvent e) {
isAutoScroll = !e.getValueIsAdjusting();
}
This has the effect of not scrolling while the mouse is dragging the
thumb and resuming scrolling when the mouse is released. Of course,
other schemes are possible. A user preference wouldn't be unwarranted.
> This desired behaviour is something I think JScrollPane should always
> do, not just in Vercheck.
I'd think it depends the content, as with text components.
[1]<http://tips4java.wordpress.com/2008/10/22/text-area-scrolling/>
[2]<http://download.oracle.com/javase/7/docs/api/javax/swing/text/DefaultCaret.html>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
fighting over the scroller Roedy Green <see_website@mindprod.com.invalid> - 2011-09-20 13:51 -0700
Re: fighting over the scroller "John B. Matthews" <nospam@nospam.invalid> - 2011-09-20 19:15 -0400
Re: fighting over the scroller Roedy Green <see_website@mindprod.com.invalid> - 2011-09-20 23:21 -0700
Re: fighting over the scroller "John B. Matthews" <nospam@nospam.invalid> - 2011-09-22 13:41 -0400
Re: fighting over the scroller Roedy Green <see_website@mindprod.com.invalid> - 2011-09-22 18:34 -0700
Re: fighting over the scroller "John B. Matthews" <nospam@nospam.invalid> - 2011-09-22 23:26 -0400
csiph-web