Skip to content

Invisible menu bar in java apps #192

@uli42

Description

@uli42

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


Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions