void (@NotNull JComponent target, @NotNull Painter painter, @NotNull Disposable parent) { final UiNotifyConnector connector = UiNotifyConnector.installOn(target, new Activatable() { private IdeGlassPane myPane; private Disposable myPanePainterListeners = Disposer.newDisposable(); @Override public void showNotify() { IdeGlassPane pane = find(target); if (myPane != null && myPane != pane) { Disposer.dispose(myPanePainterListeners); } myPane = pane; myPanePainterListeners = Disposer.newDisposable("PanePainterListeners"); Disposer.register(parent, myPanePainterListeners); myPane.addPainter(target, painter, myPanePainterListeners); } @Override public void hideNotify() { Disposer.dispose(myPanePainterListeners); } }); Disposer.register(parent, connector); }