Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endless loop if button in Toolbar has focus and is made invisible #884

Closed
PikeTec opened this issue Sep 11, 2024 · 1 comment
Closed

Endless loop if button in Toolbar has focus and is made invisible #884

PikeTec opened this issue Sep 11, 2024 · 1 comment
Milestone

Comments

@PikeTec
Copy link

PikeTec commented Sep 11, 2024

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.

DevCharly added a commit that referenced this issue Sep 29, 2024
@DevCharly
Copy link
Collaborator

Thanks for reporting and your analysis. You're right 👍

fixed in latest 3.6-SNAPSHOT: https://github.com/JFormDesigner/FlatLaf#snapshots

@DevCharly DevCharly added this to the 3.6 milestone Sep 29, 2024
@DevCharly DevCharly modified the milestones: 3.6, 3.5.2 Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants