-
Bug
-
Resolution: Fixed
-
P3
-
6, 6u10, 6u18, 6-pool, 7
-
b20
-
generic, x86
-
generic, linux, windows_xp
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2151092 | 6u23 | Karunakar Gajjala | P3 | Resolved | Fixed | b01 |
JDK-2177771 | 6u18 | Alexander Potochkin | P3 | Closed | Won't Fix |
Platform: Windows XP SP2
There are several bugs in menu item layout (see the attached test case MenuItemLayoutProblems):
1. Accelerator texts are layouted in a wrong way if menu orientation is Right-to-Left. See the "First R2L" menu ("Text and Accelerator" and "CheckBox, icon and Accelerator" items).
2. If there are items with the "CENTER" text alignment, menu item preferred size is wider, than must be. See the "Second L2R" and "Second R2L" menus.
3. If icon is wider than text and text alignment is the "CENTER", menu item is layouted in a wrong way. See the "Second L2R" and "Second R2L" menus (the "small text" item).
4. If the horizontal alignment of an menu item differs from the default (LEADING), text and icon of all menu items in the same menu are out of view. See the "Third L2R" and "Third R2L" menus.
5. Under GTK LaF icons of check box and radio menu items are shifted by couple of pixels relative to icons of other menu items. Select GTK LaF and see the "First L2R" and "First R2L" menus.
6. Under GTK LaF the accelerator text sometimes overlaps with the text of menu item. Select GTK LaF and see the "Second L2R" menu ("Radio Button, icon at the center and below text" and "Check Box, icon at the center and above text" items)
There is another user reported bug: http://forums.java.net/jive/thread.jspa?messageID=188078𭺮
One of Substance users has reported a regression behaviour on menu items.
The test case is below. If run under 5.0, the texts are not aligned (usual behaviour). Under 6.0, the texts are aligned, but the icon of the first menu item overlaps with the text of that item. Note that this test case requires menu items with icons of different size + the smaller one being installed on checkbox menu item.
In addition, when this test is run in WindowsLookAndFeel, the text alignment and icon alignment is OK (no overlapping), but the check mark of radio button menu item has (hard) square bottom left corner.
Most likely it is a regression of the fix for 4729669 (1.4 REGRESSION: Text edge of different types of JMenuItems are not aligned) introduced in Mustang.
=============Source start===============
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
public class NewBugTest extends JFrame {
NewBugTest() {
JMenuBar jmb = new JMenuBar();
JMenu menu = new JMenu("menu");
menu.add(new JMenuItem("item1", new Icon() {
public int getIconHeight() {
return 16;
}
public int getIconWidth() {
return 16;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setColor(Color.red);
g2.fillRect(x, y, 15, 15);
g2.dispose();
}
}));
menu.add(new JCheckBoxMenuItem("item2", new Icon() {
public int getIconHeight() {
return 8;
}
public int getIconWidth() {
return 8;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setColor(Color.red);
g2.fillRect(x, y, 7, 7);
g2.dispose();
}
}));
JRadioButtonMenuItem menuItem3 = new JRadioButtonMenuItem("item3");
menuItem3.setSelected(true);
menu.add(menuItem3);
jmb.add(menu);
this.setJMenuBar(jmb);
this.setSize(200, 200);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new MetalLookAndFeel());
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new NewBugTest().setVisible(true);
}
});
}
}
=============Source end===============
The description of a duplicate bug (6745220):
FULL PRODUCT VERSION :
Any version of Tiger and Mustang
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The menu accelerators under RTL layout are not aligned correctly.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create an application with different menu items and set frame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
The accelerator texts are not aligned and many of them are cur by the window itself. See many screenshots of Metal, Windows and third-party LAFs that inherit them at http://weblogs.java.net/blog/kirillcool/archive/2006/02/aligning_menu_i_1.html
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Accelerator texts are aligned
ACTUAL -
Accelerator texts are partlt cut and not aligned
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
As described in https://looks.dev.java.net/issues/show_bug.cgi?id=111 the line
accOffset = maxValue - acceleratorRect.width;
(613 in Tiger) should be replaced by
accOffset = menuItem.getComponentOrientation().isLeftToRight()
? maxValue - acceleratorRect.width
: acceleratorRect.width - maxValue;
- backported by
-
JDK-2151092 Bugs in menu item layout
- Resolved
-
JDK-2177771 Bugs in menu item layout
- Closed
- duplicates
-
JDK-6449338 JMenuitem titles not painted if horizontal alignment is not LEFT nor LEADING
- Closed
-
JDK-6462368 JMenuItem Icon not displayed in JMenuBar
- Closed
-
JDK-6505526 Calling JMenuItem.setHorizontalAlignment() makes text of item invisible
- Closed
-
JDK-6442221 No changes accepted in menu items layout
- Closed
-
JDK-6745220 Accelerator texts not aligned correctly in RTL menus
- Closed
-
JDK-6408269 Refactoring: Move layout code from BasicMenuItemUI.getPreferredMenuItemSize() into DefaultMenuLayout
- Closed
- relates to
-
JDK-6736649 test/closed/javax/swing/JMenuItem/6458123/ManualBug6458123.java fails on Linux
- Resolved
-
JDK-6568559 JPopupMenu has incorrect size when it contains Icons and Text JMenuItems
- Closed
-
JDK-6464003 Text truncated in JLabel
- Closed
-
JDK-6687241 JMenuItemTest character truncation of right-to-left menuitem in GTK+ LookAndFeel
- Closed
-
JDK-6840112 NimbusLAF JMenu
- Closed
-
JDK-7024514 Performance regression in Oracle Open Office
- Closed
-
JDK-6797139 JButton title is truncating for some strings irrespective of preferred size.
- Resolved
-
JDK-6857360 NimbusLAF: Menu indicator looks ugly with RTL orientation.
- Resolved
-
JDK-6883341 SWAT: jdk7-b72 swat build(2009-09-17) threw exceptions when running Java2D demo by clicking Paint ta
- Resolved
-
JDK-4729669 1.4 REGRESSION: Text edge of different types of JMenuItems are not aligned
- Resolved
-
JDK-6997384 Compilation Error in test\javax\swing\JMenuItem\6458123\bug6458123.java
- Closed
-
JDK-6997390 test/javax/swing/JMenuItem/6458123/bug6458123.java is failing to compile and run.
- Closed
-
JDK-6584657 GTK Look and Feel: Bugs in menu item layout
- Closed
-
JDK-7024612 Different behavior in Synth-LaF between Java 1.6.0_23/24 and previous versions
- Closed