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

REGRESSION: Descriptive text and accelerator text overlap on JMenuItem.

XMLWordPrintable

    • b80
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b71)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b71, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Under certain circumstances the descriptive text and accelerator text overlap on JMenuItems.
      This behaviour occurs in the following situation:
      An entry earlier in the menu has an accelerator set on it (eg Ctrl+L) and no icon.
      A later entry possesses an icon and the descriptive text is shorter than the previous entry.

      The resulting width of the JMenu seems to completley ignore the extra size required by the accelerator text and overlaps it with the descriptive text.



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      public class MenuTest{
      public static void main(String[] args){
      int modifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
      ImageIcon im = new ImageIcon(Toolkit.getDefaultToolkit().getImage("Document.gif"));

      JMenuItem shortitem1 = new JMenuItem("Short",im);
      JMenuItem longitem1 = new JMenuItem("Very long menu entry");
      longitem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,modifier));
      JMenu testmenu1 = new JMenu("Test1");
      testmenu1.add(shortitem1);
      testmenu1.add(longitem1);

      JMenuItem shortitem2 = new JMenuItem("Short",im);
      JMenuItem longitem2 = new JMenuItem("Very long menu entry");
      longitem2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,modifier));
      JMenu testmenu2 = new JMenu("Test2");
      testmenu2.add(longitem2);
      testmenu2.add(shortitem2);

      JMenuItem shortitem3 = new JMenuItem("Short");
      JMenuItem longitem3 = new JMenuItem("Very long menu entry");
      longitem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,modifier));
      JMenu testmenu3 = new JMenu("Test3");
      testmenu3.add(longitem3);
      testmenu3.add(shortitem3);

      JMenuItem shortitem4 = new JMenuItem("Short",im);
      JMenuItem longitem4 = new JMenuItem("Very long menu entry",im);
      longitem4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,modifier));
      JMenu testmenu4 = new JMenu("Test4");
      testmenu4.add(longitem4);
      testmenu4.add(shortitem4);

      JMenuItem shortitem5 = new JMenuItem("Short",im);
      JMenuItem longitem5 = new JMenuItem("Very long menu entry");
      shortitem5.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,modifier));
      longitem5.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,modifier));
      JMenu testmenu5 = new JMenu("Test5");
      testmenu5.add(longitem5);
      testmenu5.add(shortitem5);

      JMenuBar appmenu = new JMenuBar();
      appmenu.add(testmenu1);
      appmenu.add(testmenu2);
      appmenu.add(testmenu3);
      appmenu.add(testmenu4);
      appmenu.add(testmenu5);
      JFrame f = new JFrame();
      f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      f.setJMenuBar(appmenu);
      f.setVisible(true);
      f.pack();
      f.setLocationRelativeTo(null);
      }
      }
      ---------- END SOURCE ----------

      Release Regression From : 5.0u6
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

            mlapshin Mikhail Lapshin (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: