JCEF heavyweight popup closes too early or always stays on top Follow
Given the following code:
//--------------- Attempt 1 ---------------
val browser = JBCefBrowser()
browser.loadHTML("<html><body><h1>Hello World</h1></body></html>")
browser.component.preferredSize = Dimension(400, 400)
val popup = JBPopupFactory.getInstance()
.createComponentPopupBuilder(browser.component, browser.component)
.setShowBorder(false)
.setShowShadow(false)
.setRequestFocus(true)
.setCancelOnWindowDeactivation(true)
.createPopup()
popup.showInFocusCenter()
If you click the browser that appears, it will immediately disappear. Sometimes you have to click a few times but it will immediately disappear.
You can see this behavior here:
I've solved this problem by using this code:
//--------------- Attempt 2 ---------------
val browser = JBCefBrowser()
browser.loadHTML("<html><body><h1>Hello World</h1></body></html>")
browser.component.preferredSize = Dimension(400, 400)
val popup = JBPopupFactory.getInstance()
.createComponentPopupBuilder(browser.component, browser.component)
.setShowBorder(false)
.setShowShadow(false)
.setRequestFocus(true)
.setCancelOnWindowDeactivation(false) //<< only difference
.createPopup()
popup.showInFocusCenter()
But now the popup will not close when you leave the IDE. It will close if you click somewhere in the IDE but if you minimize the IDE and click outside of the IDE, it will always remain on top of everything:
I've been trying for a few days to figure this out and I'm not making any progress. I don't understand why the first attempt closes when you click it and no matter what type of listeners I add I can't seem to grab an event that indicates the IDE is no longer in focus. I've added FocusListeners/WindowListeners/etc and even listening to ApplicationActivationListener events but nothing will fire once you click inside the popup.
I've made a tiny project for re-creating this issue: https://github.com/BFergerson/hide-heavy-popup
To make the popup appear you have use the shortcut "Control+Shift+S"
Please sign in to leave a comment.
Brandon,
Thanks for reporting that. Unfortunately, I was not able to reproduce any of the scenarios on
Can I ask you to file an issue on YouTrack?