In my application i have a JPanel filled with Swing components. I have to zoom this JPanel within a JScrollPane.
I already wrote a JZoomPane, which has a paint method like
public void paint(Graphics g) {
if (zoomFactor != 1) {
Graphics2D g2 = (Graphics2D)g;
g2.scale(zoomFactor, zoomFactor);
}
super.paint(g);
}
There are two problems i don't know how to solve:
1. To manage the repainting, i know i have to write my own RepaintManager, but i don't know which part i have to customize.
2. I have to catch the MouseEvents and transform them against the zoom factor. But i can't use the GlassPane because i have to zoom only the part in the JScrollPane and not the rest of the application. I experimented a little bit with JLayeredPanes but couldn't get them to work.
Could anybody help me or, even better, send me some sample code.
Thanks,
Oliver