void () { if (!isShowing()) { return; } Window mywindow = SwingUtilities.windowForComponent(ButtonToolbarImpl.this); if (mywindow != null && !mywindow.isActive()) 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) final MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager(); final MenuElement[] selectedPath = menuSelectionManager.getSelectedPath(); if (selectedPath.length > 0) { return; } // don't update toolbar if there is currently active modal dialog final Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow(); if (window instanceof Dialog dialog) { if (dialog.isModal() && !SwingUtilities.isDescendingFrom(ButtonToolbarImpl.this, dialog)) { return; } } updateActions(); }