[reposted here - earlier incorrectly posted to comp.lang.java.help]
Anyone know a way of allowing a JPanel to be zoomable not only in terms of
how it draws itself, but also so any JComponents within the (zoomed) panel
behave correctly?
In particular, anyone know a clean way of avoiding these two problems -
1. The JRE's mouse system looking in the untransformed co-ordinate space:
From what I can see, the code the JRE calls
Java.awt.Container.findComponent(int, int, boolean) to find the component
under the mouse to deliver a mouse click event to. This method is final,
and so can't be overridden to make it look in the transformed coordinate
space. (This means that where you need to click to click on a button isn't
always where the button appears to be.)
2. not all paint calls seem to come through the component hierarchy. Eg, if
a JComponent calls setBackground(java.awt.Color.blue), a repaint call seems
to happen directly on the JComponent, and the zoomable JPanel does not get
a chance to apply the transform to the Graphics2D object. (This means a
component will sometimes suddenly draw itself in the untransformed space,
making it appear in a different place and size on the screen)
cheers,
Will Billingsley
Mr.Cube - 06 Apr 2004 21:03 GMT
> [reposted here - earlier incorrectly posted to comp.lang.java.help]
>
> Anyone know a way of allowing a JPanel to be zoomable not only in terms of
> how it draws itself, but also so any JComponents within the (zoomed) panel
> behave correctly?
Take a look at the jazz toolkit.
It is a zui (zoomable user interface) which can embed swing components.
(jazz is the predecessor of piccolo which helas doesn't have zoomable
swing components yet).
It's opensource and you can find it at :
http://www.cs.umd.edu/hcil/jazz/
Kees.