Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8217320

Unresponsive menu items overlapping taskbars on CENTOS

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      CentOS Linux release 7.5.1804 (Core)
      GNOME Shell 3.25.4
      Java 9:
      java version "9.0.4"
      Java(TM) SE Runtime Environment (build 9.0.4+11)
      Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
      Java 11:
      java version "11.0.1" 2018-10-16 LTS
      Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
      Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
      Java 13 (ea):
      openjdk version "13-ea" 2019-09-17
      OpenJDK Runtime Environment (build 13-ea+2)
      OpenJDK 64-Bit Server VM (build 13-ea+2, mixed mode, sharing)
      All tests were performed with a 4K monitor and VNC was used with Linux testing.



      A DESCRIPTION OF THE PROBLEM :
      On CENTOS sometimes popup menu items overlap taskbars. When this happens the menu items that are over the taskbars receive no mouse events. This is most apparent when rolling over or trying to select the menu items. I wrote a small program to test this. I tested this on CENTOS using Java 9, Java 11, and Java 13 ea. I also used the same program to confirm that the issue does not show up on Redhat 6 or on Windows 10.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. obtain my small test program or create your own program that displays a menu on a frame with many (several dozen) menu items.
      2. Build and run this program on CENTOS 7.x.
      3. Open the menu and observe that depending on the size of your screen, the location of your test program on the screen, and the number of menu items the menu has, Java will render the menu items such that either the top of the first menu item is flush with the top of the screen display bounds or the bottom of the last menu item is flush with the bottom of the screen display bounds.
      4. Note that the menu items (from #3) will overlap one of CENTOS's taskbars (either the bar at the top or the bar at the bottom).
      5. Mouse over the menu items and notice that for menu items that do not overlap taskbars a rollover effect is visible, but for menu items that do overlap taskbars no rollover effect is visible.
      6. If you add an action handler to your menu items you will also notice that you cannot invoke the action (via mouse click) on those menu items that overlap taskbars. Basically no mouse events reach those menu items.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected results are that menu items regardless of position on the screen and whether or not they overlap taskbars will respond to mouse events.
      ACTUAL -
      Actual results are that menu items that overlap taskbars on CENTOS do not respond to mouse events.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.*;
      import java.util.*;

      // test program for Java/CENTOS menu overlapping taskbar issue
      // justin tucker 1-9-2018
      public class Main extends JFrame {
              public static void main(String[] args) {
                      SwingUtilities.invokeLater(new Runnable() {
                              public void run() {
                                      JMenuBar menuBar = new JMenuBar();
                                      JMenu menu = new JMenu("A menu");
                                      menuBar.add(menu);

                                      for (int i = 0; i < 50; i++) {
                                              String caption = "menu item #" + i;
                                              JMenuItem menuItem = new JMenuItem(caption);
                                              menu.add(menuItem);
                                      }

                                      Main frame = new Main();
                                      frame.setPreferredSize(new Dimension(200, 200));
                                      frame.setJMenuBar(menuBar);
                                      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                                      frame.pack();
                                      frame.setLocationRelativeTo(null);
                                      frame.setVisible(true);
                              }
                      });
              }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      1. Users can relocate and/or resize the native window owner of the menu so that the fully displayed menu does not overlap taskbars (assuming there are not too many menu items).
      2. It might be possible to override JPopupMenu's show method and reposition the menu to avoid menu items overlapping taskbars (I haven't tried this yet).

      FREQUENCY : always


            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: