Skip to content

JetBrains: Properly set z-index when configuring JLayeredPane

Administrator requested to merge ps/jetbrains-fix-jlayerdpane-issue into main

Created by: philipp-spiess

We have gotten bug reports about loading indicator displaying forever for some Linux users on Debian.

Upon investigation, the web view seems to be loading correctly which got me into researching issues with the Java UI hierarchy.

I noticed that removing the JLayeredPane and mounting the browser component directly would make it work in these scenarios, which lead me to look into the JLayeredPane implementation.

The official documentation used a weird syntax for adding panes which got me thinking. Instead of add(Component, integer) it was casting the integer to an object, using a different overlay of the add method add(Component, Object) (You can learn more about these overloads here.

It turns out that add(Component, integer) would only define the index in which a component rendered but would not set a constraint that the layout implementation would later use to properly align the z-axis. To give JLayeredComponent this information, we have to use the add(Component, Object) overload and thus cast the integer to an Object (or Integer our case, which is the boxed object representation of integer`.

Without providing a constraint, the default z-axis behavior was undefined which explains the differences between macOS and Linux.

Test plan

I tested on Linux (Debian) and macOS to avoid regression. Here's a very bad quality video (lol the remote VM isn't very fast) that shows that this is working now:

https://user-images.githubusercontent.com/458591/176662639-2688cef2-0d16-48cd-8ca6-32c4cd91936e.mov

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading