@Override public void gestureBegan(GesturePhaseEvent event) { magnification = 0; Point mouse = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(mouse, myFrame.getComponent()); Component deepest = SwingUtilities.getDeepestComponentAt(myFrame.getComponent(), mouse.x, mouse.y); ZoomableViewport viewport = (ZoomableViewport) SwingUtilities.getAncestorOfClass(ZoomableViewport.class, deepest); if (viewport != null) { Magnificator magnificator = viewport.getMagnificator(); if (magnificator != null) { Point at = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(at, (JComponent)viewport); viewport.magnificationStarted(at); myMagnifyingViewport = viewport; } } }