void () { ToolbarUpdater updater = myReference.get(); if (updater == null) return; if (!updater.myComponent.isShowing()) { return; } // do not update when a popup menu is shown (if popup menu contains action which is also in the toolbar, it should not be enabled/disabled) MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager(); MenuElement[] selectedPath = menuSelectionManager.getSelectedPath(); if (selectedPath.length > 0) { return; } // don't update toolbar if there is currently active modal dialog Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow(); if (window instanceof Dialog && ((Dialog)window).isModal() && !SwingUtilities.isDescendingFrom(updater.myComponent, window)) { return; } updater.updateActions(false, false, false); }