-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
hopper
-
x86
-
windows_2000
-
Verified
Name: jk109818 Date: 12/05/2001
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/** Goal: put [logo] at trailing (right) end of menu bar, away from menus
in left to right orientation, and opposite in right-to-left orientation.
+-----------------------------------+
|File Edit [logo]|
+-----------------------------------+
| |
...
+-----------------------------------+
|[logo] Edit File|
+-----------------------------------+
| |
...
Bug: in right-to-left orientation, horizontal glue is not honored.
+-----------------------------------+
| [logo] Edit File|
+-----------------------------------+
| |
It appears that BasicMenuBarUI uses DefaultMenuLayout extends BoxLayout
for left-to-right, but RightToLeftMenuLayout extends FlowLayout for
right-to-left.
BoxLayout has been updated (jdk1.4) to handle right-to-left
orientation when LINE_AXIS is specified.
BasicMenuBarUI needs to be updated so BoxLayout(LINE_AXIS)
is used in both cases.
**/
public class MenuBarLogo {
public static void main(String[] ignore) {
JFrame frame = new JFrame("MenuBarLogo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new GridLayout(2,1));
frame.getContentPane().add(makePane(ComponentOrientation.LEFT_TO_RIGHT));
frame.getContentPane().add(makePane(ComponentOrientation.RIGHT_TO_LEFT));
frame.setSize(300,80);
frame.show();
}
static JComponent makePane(ComponentOrientation orientation) {
JMenuBar menuBar = new JMenuBar(); {
//menuBar.setLayout(new BoxLayout(menuBar, BoxLayout.LINE_AXIS));
menuBar.setComponentOrientation(orientation);
menuBar.add(new JMenu("File"));
menuBar.add(new JMenu("Edit"));
menuBar.add(Box.createHorizontalGlue());
menuBar.add(new JLabel("[Logo]"));
}
return menuBar;
}
}
(Review ID: 136773)
======================================================================