Hi,
I need to add zoom functionality to my swing based editor. My editor contains a JScrollPane constructed with a JDeskTopPane as the constructor argument.
The JDeskTopPane contains further controls like JTextFields, JLabels , Shapes etc. For zooming functionality the approach I'm using is to create my own class say ViewPane that extends JDesktopPane and construct the JScrollPane with an instance of this class. ViewPane has a paintComponent() method which is like
public void paintComponent(Graphics g)
{
Graphics2D g2d = (Graphics2D)g;
g2d.scale(1.5, 1.5);// hardcoded here for a fixed magnificaction
super.paintComponent(g2d);
}
The problem is that when the editor becomes visible for the first time , I get the magnified view with some portion of the original view overlapping on the magnified view. This problem disappears once I minimize the main frame and then maximize it. However if I double click on any of the text controls , the control on the page that would have been at the position I double clicked if I had not scaled, becomes visble overlapped with the text control I double clicked. I'm really confused why this is happening.
Regards
Nikhil.