void (Component eventSource, Point eventPoint) { JRootPane newRootPane = SwingUtilities.getRootPane(eventSource); JRootPane oldRootPane = this.rootPane.getAndSet(newRootPane); if (newRootPane != oldRootPane) { Optional.ofNullable(oldRootPane).ifPresent(this::removePainter); Optional.ofNullable(newRootPane).ifPresent(this::installPainter); } if (newRootPane != null) { Point point = SwingUtilities.convertPoint(eventSource, eventPoint, newRootPane); finder.update(newRootPane, point); Component glassPane = newRootPane.getGlassPane(); if (glassPane instanceof IdeGlassPane) { setNeedsRepaint(true, glassPane); } else if (glassPane instanceof ThiefGlassPane) { glassPane.repaint(); } else { throw new IllegalStateException("GlassPane maybe only IdeGlassPane or ThiefGlassPane but found " + glassPane); } } }