-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 6
-
b80
-
x86
-
windows_xp
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.
- relates to
-
JDK-4729669 1.4 REGRESSION: Text edge of different types of JMenuItems are not aligned
- Resolved
-
JDK-6197830 Fix for 4729669 does not work on Motif and GTK look and feels
- Resolved
-
JDK-6438430 Regression: Submenu title overlaps with Submenu indicator in JPopupMenu
- Closed
-
JDK-4199382 Swing Menus - text/icon/checkmark alignment schemes severely broken
- Closed
-
JDK-6181935 Swing Menu items with and without images should be aligned
- Closed
-
JDK-4991607 Wrong insets for JMenuItem with icon and text
- Closed
-
JDK-6408269 Refactoring: Move layout code from BasicMenuItemUI.getPreferredMenuItemSize() into DefaultMenuLayout
- Closed