-
Bug
-
Resolution: Fixed
-
P4
-
1.1.6
-
beta2
-
generic
-
generic
Name: moC74494 Date: 06/12/98
We've run across another item in Swing that should get its default values from the L&F instead of the component.
The issue is with JMenuItems. They hard-code the default relative positions of the text relative to the icons on the menu item to be horizontally JButton.LEFT. This choice is only true for left to right reading cultures, not right to left readers (Hebrew, Arabic).
To make the behavior even more confusing, JMenuItems created through using the JMenu.add(Action) method _use different defaults_. The add(Action) method explicitly sets the relative positioning to be JButton.RIGHT.
The L&F should be queried for the default positions, since this is a L&F wide issue that applies to all apps that use the same L&F.
Swing 1.0.2:
JMenuItem.java
public JMenuItem(String text, Icon icon) {
setModel(new DefaultButtonModel());
init(text, icon);
setBorderPainted(false);
setFocusPainted(false);
setHorizontalTextPosition(JButton.LEFT);
setHorizontalAlignment(JButton.LEFT);
updateUI();
}
JMenu.java
public JMenuItem add(Action a) {
JMenuItem mi = new JMenuItem((String)a.getValue(Action.NAME),
(Icon)a.getValue(Action.SMALL_ICON));
mi.setHorizontalTextPosition(JButton.RIGHT);
mi.setVerticalTextPosition(JButton.CENTER);
mi.setEnabled(a.isEnabled());
mi.addActionListener(a);
add(mi);
PropertyChangeListener actionPropertyChangeListener =
createActionChangeListener(mi); a.addPropertyChangeListener(actionPropertyChangeListener);
return mi;
}
(Review ID: 33512)
======================================================================