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

Invisible menu bar in java apps #192

Open
uli42 opened this issue Aug 2, 2016 · 6 comments
Open

Invisible menu bar in java apps #192

uli42 opened this issue Aug 2, 2016 · 6 comments
Labels
Milestone

Comments

@uli42
Copy link
Member

uli42 commented Aug 2, 2016

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:
    missing_menubar

  • move the example window -> menu bar appears:
    after_movement


@uli42 uli42 changed the title Invisible Menubar in java apps Invisible menu bar in java apps Aug 2, 2016
@uli42
Copy link
Member Author

uli42 commented Aug 6, 2016

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

@uli42
Copy link
Member Author

uli42 commented Aug 9, 2016

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.

@woglinde
Copy link
Member

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

@uli42
Copy link
Member Author

uli42 commented Aug 10, 2016

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

@sunweaver sunweaver added the bug label Oct 28, 2016
@sunweaver sunweaver added this to the 3.6.0.0 milestone Mar 2, 2017
@uli42
Copy link
Member Author

uli42 commented Dec 11, 2017

This is still happening with today's HEAD (3731a99), also with openjdk-1.8.0.151-1.b12

@uli42
Copy link
Member Author

uli42 commented Dec 17, 2019

see #830 for a patch passing down WM information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants