I jave a JPanel within a JScrollPane; that JPanel contains numerous image thumbnails. Currently, I allow users to drag a marquee box over various images, thus "selecting" those image (nothing out of the ordinary there, much like any similar program would do).
More often than not, there are more image thumbnails below the fold, where the user would need to scroll down to get to. I realized that if the user attempt to drag the marquee below the fold, the JPanel should autoscroll, allowing the marquee to select the images down below.
So, has anyone implemented something like this? I know there is the Autoscroll interface, but that is designed only to work with DnD. If my JPanel isn't associated with a DropTargetListener, and more importantly if I'm not actually dragging a DragSource through it, the Autoscroll mechanism won't work. I'm curious if the API offers something similar to those of us who aren't doing Drag & Drop, but merely Drag.
Dave Taubler<br />Specializing in <a href="http://taubler.com/articles/" target="_blank" rel="nofollow">Java and Web Development</a>
That got me on the right track. In my case, I had to make a second Rectangle r, based on the marquee's position, to scrollRectToVisible(r). That's because my marquee could grow in size to be larger than the scrollable viewport.
The only trick now is to make it autoscroll even if the user isn't currently moving their mouse; right now, the user needs to not only drag the cursor below the fold, but also wiggle it around a bit to fire off those mouse drag events. But hopefully I can spawn off a Thread to handle that.
Thanks again!
Dave Taubler<br />Specializing in <a href="http://taubler.com/articles/" target="_blank" rel="nofollow">Java and Web Development</a>
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad: