Home » Category » Swing / AWT / SWT / JFace

Swing / AWT / SWT / JFace: Zooming problem

300| Fri, 21 Sep 2007 19:57:00 GMT| patniksa| Comments (1)
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.

Keywords & Tags: zooming, swing, awt, swt, jface

URL: http://java.itags.org/java-swing/50409/
 
«« Prev - Next »» 1 helpful answers below.
schedule JScrollPane.validate():JScrollPane.repaint(); using SwingUtilities.invokeLater(Runnable); at the end of your init(), this should paint it properly as the first event after the GUI is first drawn.Bamkin

bamkin_ov_lestaa | Sun, 15 Jul 2007 22:00:00 GMT |

Swing / AWT / SWT / JFace Hot Answers

Swing / AWT / SWT / JFace New questions

Swing / AWT / SWT / JFace Related Categories