diff --git a/CHANGELOG.md b/CHANGELOG.md index a4eaf1cf0..6b3c9cb75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ FlatLaf Change Log using custom component that overrides `Component.contains(int x, int y)` and invokes `SwingUtilities.convertPoint()` (or similar) from the overridden method. (issue #878) +- ToolBar: Fixed endless loop if button in Toolbar has focus and is made + invisible. (issue #884) ## 3.5.1 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarUI.java index 760202c35..7d97d8168 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarUI.java @@ -531,8 +531,11 @@ public Component getLastComponent( Container aContainer ) { private Component getRecentComponent( Container aContainer, boolean first ) { // if moving focus into the toolbar, focus recently focused toolbar button - if( focusedCompIndex >= 0 && focusedCompIndex < toolBar.getComponentCount() ) - return toolBar.getComponent( focusedCompIndex ); + if( focusedCompIndex >= 0 && focusedCompIndex < toolBar.getComponentCount() ) { + Component c = toolBar.getComponent( focusedCompIndex ); + if( accept( c ) ) + return c; + } return first ? super.getFirstComponent( aContainer )