mirror of
https://github.com/openjdk/jdk17u.git
synced 2025-12-11 11:33:49 -06:00
8370465: Right to Left Orientation Issues with MenuItem Component
Backport-of: aeb92e8d9059ca37000a6d92fbf5079a919f812c
This commit is contained in:
parent
78564fd250
commit
a8784a0408
@ -882,8 +882,15 @@ public class WindowsIconFactory implements Serializable
|
||||
}
|
||||
}
|
||||
if (icon != null) {
|
||||
icon.paintIcon(c, g, x + VistaMenuItemCheckIconFactory.getIconWidth(),
|
||||
y + OFFSET);
|
||||
if (WindowsGraphicsUtils.isLeftToRight(c)) {
|
||||
icon.paintIcon(c, g,
|
||||
x + VistaMenuItemCheckIconFactory.getIconWidth(),
|
||||
y + OFFSET);
|
||||
} else {
|
||||
icon.paintIcon(c, g,
|
||||
x - VistaMenuItemCheckIconFactory.getIconWidth() + 2 * OFFSET,
|
||||
y + OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static WindowsMenuItemUIAccessor getAccessor(
|
||||
|
||||
@ -43,6 +43,7 @@ import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.UIResource;
|
||||
@ -215,8 +216,17 @@ public class WindowsMenuItemUI extends BasicMenuItemUI {
|
||||
|
||||
if (lh.getCheckIcon() != null && lh.useCheckAndArrow()) {
|
||||
Rectangle rect = lr.getTextRect();
|
||||
|
||||
rect.x += lh.getAfterCheckIconGap();
|
||||
if (menuItem.getComponentOrientation().isLeftToRight()) {
|
||||
if (menuItem.getHorizontalTextPosition() != SwingConstants.LEADING
|
||||
&& menuItem.getHorizontalTextPosition() != SwingConstants.LEFT) {
|
||||
rect.x += lh.getAfterCheckIconGap();
|
||||
}
|
||||
} else {
|
||||
if (menuItem.getHorizontalTextPosition() != SwingConstants.LEADING
|
||||
&& menuItem.getHorizontalTextPosition() != SwingConstants.RIGHT) {
|
||||
rect.x -= lh.getAfterCheckIconGap();
|
||||
}
|
||||
}
|
||||
|
||||
lr.setTextRect(rect);
|
||||
}
|
||||
@ -232,7 +242,11 @@ public class WindowsMenuItemUI extends BasicMenuItemUI {
|
||||
}
|
||||
if (lh.getCheckIcon() != null && lh.useCheckAndArrow()) {
|
||||
Rectangle rect = lr.getAccRect();
|
||||
rect.x += lh.getAfterCheckIconGap();
|
||||
if (menuItem.getComponentOrientation().isLeftToRight()) {
|
||||
rect.x += lh.getAfterCheckIconGap();
|
||||
} else {
|
||||
rect.x -= lh.getAfterCheckIconGap();
|
||||
}
|
||||
lr.setAccRect(rect);
|
||||
}
|
||||
SwingUtilities3.paintAccText(g, lh, lr, disabledForeground,
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
/*
|
||||
* @test id=windows
|
||||
* @bug 4211052
|
||||
* @bug 4211052 8370465
|
||||
* @requires (os.family == "windows")
|
||||
* @summary Verifies if menu items lay out correctly when their
|
||||
* ComponentOrientation property is set to RIGHT_TO_LEFT.
|
||||
@ -155,6 +155,16 @@ public class RightLeftOrientation {
|
||||
menuItem.setHorizontalTextPosition(SwingConstants.LEADING);
|
||||
menu.add(menuItem);
|
||||
|
||||
menuItem = new JMenuItem("Text to the left", new MyMenuItemIcon());
|
||||
menuItem.setComponentOrientation(o);
|
||||
menuItem.setHorizontalTextPosition(SwingConstants.LEFT);
|
||||
menu.add(menuItem);
|
||||
|
||||
menuItem = new JMenuItem("Text to the right", new MyMenuItemIcon());
|
||||
menuItem.setComponentOrientation(o);
|
||||
menuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
|
||||
menu.add(menuItem);
|
||||
|
||||
menuItem = new JRadioButtonMenuItem("Radio Button Menu Item");
|
||||
menuItem.setComponentOrientation(o);
|
||||
menuItem.setSelected(true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user