nx-libs
nx-libs copied to clipboard
Invisible menu bar in java apps
When running the example from http://alvinalexander.com/java/java-menubar-example-jmenubar-jframe in a rootless x2go session the window gets shown but the menu bar is not visible until the window is moved or resized. This happens (for me) in about 85% of all starts. It does not happen with all window managers since some of them take care of placing the window and this seems to trigger a event for the example program so that the window gets repainted. I was able to see this in Unity and sometimes kwin.
How to reproduce:
- save this stripped down version of the example somewhere:
import java.awt.*;
import javax.swing.*;
public class JavaMenuBarExample implements Runnable
{
private JFrame frame;
private JMenuBar menuBar;
private JMenu fileMenu;
public static void main(String[] args)
{
SwingUtilities.invokeLater(new JavaMenuBarExample());
}
public void run()
{
frame = new JFrame("Java Menubar Example");
menuBar = new JMenuBar();
fileMenu = new JMenu("File");
menuBar.add(fileMenu);
frame.setJMenuBar(menuBar);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(400, 300));
frame.pack();
frame.setVisible(true);
}
}
- compile it:
> javac JavaMenuBarExample.java
-
open an x2go rootless session (x2go: session type: application, command: /usr/bin/xterm)
-
run the example from the xterm:
> java JavaMenuBarExample
-> menu bar is missing:
-
move the example window -> menu bar appears:
I now figured out that this is NOT related to using the nx transport. It happens in rootless session, regardless of the transport. You can simply run
nxagent -ac -R :99
and from another shell
java JavaMenuBarExample
to trigger that bug
I have done some debugging. It looks to me like the problem is the way java tries to detect window managers. By adding some debug output for the java XWM class to the example above I can see that java does not detect a window manager in the rootless session. I think it should detect the outside window manager instead. Further, java decides that the example window`s parent ist the root window. This is true but not helpful, since the rootless root window should not be relevant here but the outside root window...
I also found a very similar bug (from 2004) in the java bug tracker: https://bugs.openjdk.java.net/browse/JDK-5023533
And: when adding debug output the problem does not happen not that often anymore. So it seems to be caused by some kind of race condition, too.
This problem often occurs when using awt/swing and a fancy window manager like awesome. Often it helps when setting
_JAVA_AWT_WM_NONREPARENTING=1; export _JAVA_AWT_WM_NONREPARENTING or faking the windowmanager with wmname Sawfish or wmname LG3D
On Wed, Aug 10, 2016 at 9:13 AM, Henning Heinold [email protected] wrote:
This problem often occurs when using awt/swing and a fancy window manager like awesome. Often it helps when setting
_JAVA_AWT_WM_NONREPARENTING=1; export _JAVA_AWT_WM_NONREPARENTING or faking the windowmanager with wmname Sawfish or wmname LG3D
I have tried all those - to no avail unfortunately...
Uli
This is still happening with today's HEAD (3731a996dce9adf1c6f398cc1cdec2909588a7ee), also with openjdk-1.8.0.151-1.b12
see #830 for a patch passing down WM information.