We are often asked how our clients use WebRenderer in their projects. There are thousands of different use cases our ingenious clients have come up with that have both delighted and surprised us. WebRenderer is more than just an embeddable Java Swing browser. WebRenderer also gives you, the developer, complete access and control of the browser.
We thought we would put together an example that demonstrates some of the in-browser functionality. In this example we use WebRenderer Swing Edition to create a special “Zoom” effect when a click action is selected, like so:
The Zoom Browser demonstrates content being displayed on top of the Java browser in a glass pane. This content is an image taken from the browser itself and modified to give a scaled view. Click with the mouse scroll wheel to show. Scroll with the wheel, navigate to a new page or press ESC to remove the display.
How do we do this? When the click is made with the scroll wheel, a buffered image is created of the visible browser content using WebRenderer. The mouse cursor coordinates from the click are used to select a corresponding section of the buffered image. From here, the section is scaled (in this case double the size) and a new image is created of the section. This new image is drawn at the click position onto an overlay, which is used as a glass pane on top of the frame containing the browser.
As long as this sub-image exists, it will be drawn whenever the overlay is painted. Since scrolling or loading a new page would change the content, the sub-image is set to null, so that it will be removed from the overlay in these cases.
You can grab the source code for this here..
And for a free 30 day trial of WebRenderer Swing Edition, head over here..