Swing / AWT / SWT / JFace: Zooming problem

  • patniksa / 300 / Wed, 24 Jun 2009 20:11:00 GMT / 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:

    zooming, swing, awt, swt, jface

  • http://java.itags.org/java-swing/50409/«« Last Thread - Next Thread »»
    1. 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 Questions

    • z-order of windows

      Is it possible to create a window in Java which will be displayed over the taskbar?I want to use the...

      By ribizlia

    • JAVA JWINDOW +PANEL

      i have an applet. It has a panel which contains a button. onclick of the button pops up a Window wit...

      By gayu1979a

    • making GlassPane visible

      I've got a JFrame.It has a menu item that creates a glassPane. When I execute the menu option I ...

      By presbrawner

    • making g.drawImage() faster?

      Hey all..I am trying to provide a faster version of drawImage on linux. I figured that singe Graphic...

      By anupenginea

    • Performance on XP

      I am using Java 1.4.1 and it seems that Swing performance is better on a 450 MH Windows 98 machine t...

      By algia, 3 Comments

    • java L&F: html on jlabel *always* bold

      I'm trying to use HTML with a JLabel that is serving as a JTable cell editor. The UI default for the...

      By irun5ka, 1 Comments

    • Data Grid

      IS THERE A COMPONENT SIMILIAR TO MSHFLEXGRID(VB) IN JAVA.IF NOT HOW CAN WE CREATE SUCH A COMPONENT...

      By mayukhghosh, 1 Comments

    • How to implement select all files (Ctrl-A) in open...

      I successfully created file open dialog. However, in most windows file open dialog,if you press "Ctr...

      By xpproject, 1 Comments

    • Data getting

      Dear Programmers,i have made one textfield and two text areas by using tabbedPane. TextField and one...

      By sandhiyasindhi, 1 Comments