diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b229d2f..7946f7de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ FlatLaf Change Log - Native window decorations (Windows 10/11 only): Fixed wrong window title character encoding used in Windows taskbar. (issue #502) +- ToolBar: Fixed endless loop in focus navigation that may occur under special + circumstances. (issue #505) ## 2.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 57f30740..fa241700 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 @@ -256,11 +256,15 @@ public class FlatToolBarUI default: return; } - for( int i = focusedCompIndex + add; i != focusedCompIndex; i += add ) { + int i = focusedCompIndex; + for(;;) { + i += add; if( i < 0 ) i = count - 1; else if( i >= count ) i = 0; + if( i == focusedCompIndex ) + break; Component c = toolBar.getComponentAtIndex( i ); if( canBeFocusOwner( c ) ) {