In GWT, how do you click and drag a large image to change the part being viewed?

In my GWT application, I am using Border Layout to display a large image in a panel that is added to the center location.

I would like to click and drag on the image to change part of the displayed image. This is equivalent to using the scroll bars to move the portion of the image displayed on the screen. This is similar to how Adobe Reader allows you to navigate a PDF file.

How can I do this using GWT?

0


a source to share


1 answer


David Geary's book "Google Web Toolkit Solutions" describes an implementation of a ViewPort that does what you describe. Basically, you are creating a subclass of AbsolutePanel that listens for mouse events. Based on these mouse events, you do your drag and drop calculations and update the position of the contained element (a large image in your case).



To see this in action, go to http://coolandusefulgwt.com/ and click Examples, then Maps. (Note that the lack of a direct link is a good example of why proper history support is important for gwt applications).

0


a source







All Articles