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

IllegalComponentStateException when invoker is not showing in SubMenuUsabilityHelper #692

Closed
rkeen-siemens opened this issue Jun 19, 2023 · 1 comment
Milestone

Comments

@rkeen-siemens
Copy link

Sometimes when opening a submenu immediately after first opening the application we are getting an exception within SubMenuUsabilityHelper:

java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
	at java.desktop/java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:2113)
	at java.desktop/java.awt.Component.getLocationOnScreen(Component.java:2087)
	at com.formdev.flatlaf.SubMenuUsabilityHelper.menuSelectionChanged(SubMenuUsabilityHelper.java:157)
	at com.formdev.flatlaf.SubMenuUsabilityHelper.lambda$stateChanged$0(SubMenuUsabilityHelper.java:119)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:136)
[catch] at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

When this happens, invoker.isShowing() is false. This may be happening because we have a dynamic popup menu that populates itself. The first call in the update is to JMenu.removeAll() which may cause it to be hidden.

In any case, adding a check for invoker.isShowing() in the conditional when getting the invoker screen bounds could avoid this issue.

DevCharly added a commit that referenced this issue Jun 20, 2023
@DevCharly
Copy link
Collaborator

Thanks for reporting 👍

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

@DevCharly DevCharly added this to the 3.2 milestone Jun 20, 2023
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