This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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>
Cool, a homespun answer! I was figuring that would be the route to take, but I thought I'd check to see if I was missing something in the API.
Anyway, thanks, Craig; I will give that a whirl.
Joined: May 15, 2001
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.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com