If a focusable button is hidden while it has the focus, the UI fill freeze due to an endless while loop executed in the AWT Thread.
A minimal a example is
public static void main(String[] args) throws UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(new FlatLightLaf());
UIManager.put("ToolBar.focusableButtons", true);
JToolBar toolbar = new JToolBar();
JButton hideMe = new JButton("click me");
hideMe.addActionListener(a -> hideMe.setVisible(false));
toolbar.add(hideMe);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(toolbar);
frame.pack();
frame.setVisible(true);
}
The problem seems to be, that com.formdev.flatlaf.ui.FlatToolBarUI.FlatToolBarFocusTraversalPolicy.getFirstComponent(Container) and com.formdev.flatlaf.ui.FlatToolBarUI.FlatToolBarFocusTraversalPolicy.getLastComponent(Container) both deliver the most recently focused component, even if this one is not visible so that the while loop in com.formdev.flatlaf.ui.FlatToolBarUI.FlatToolBarFocusTraversalPolicy.getComponentAfter(Container, Component) is stuck getting always the same component.
If a focusable button is hidden while it has the focus, the UI fill freeze due to an endless while loop executed in the AWT Thread.
A minimal a example is
The problem seems to be, that
com.formdev.flatlaf.ui.FlatToolBarUI.FlatToolBarFocusTraversalPolicy.getFirstComponent(Container)
andcom.formdev.flatlaf.ui.FlatToolBarUI.FlatToolBarFocusTraversalPolicy.getLastComponent(Container)
both deliver the most recently focused component, even if this one is not visible so that the while loop incom.formdev.flatlaf.ui.FlatToolBarUI.FlatToolBarFocusTraversalPolicy.getComponentAfter(Container, Component)
is stuck getting always the same component.