Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4071628

Solaris Only: double Menubar with the long labels

XMLWordPrintable

    • 1.1.5
    • x86
    • windows_95
    • Not verified


        ingrid.yao@Eng 1997-08-13

        Oracle reported:

        ** Change the labels on a MenuBar to show the effect on Solaris.
        **
        ** Click on the Expand Button, and the MenuBar labels are changed to be longer
        ** such that the menu extends past the end of the bar. Click on the Shrink
        ** Button and the labels are made shorter. Note that the MenuBar size (one
        ** vs. two lines) isn't correctly adjusted.
        **
        ** Manually resizing the window will fix up the MenuBar size and appearance.
        **
        ** So, click on Expand. The menu labels are made longer, but no additional
        ** space is provided for them, so all are displayed truncated. Manually
        ** expand the window width (very little), and the MenuBar expands to two
        ** lines with fully displayed menu labels. (I saw the fourth menu item overlap
        ** the right edge of the MenuBar, but this was minor.) Click on Shrink.
        ** The menu labels are restored to their original sizes, but the menu is
        ** displayed, centered, in the double height MenuBar.

        Test case
        =========

        import java.applet.*;
        import java.awt.*;
        import java.awt.event.*;
        import java.io.*;
         
        public class ChgLabel extends Applet
            implements ActionListener
        {
            Button mButton_Expand;
            Button mButton_Shrink;
            Frame mFrame;
            MenuBar mTopMenu;
            Menu mMenu1;
            Menu mMenu2;
            Menu mMenu3;
            Menu mMenu4;
         
            public ChgLabel(Frame frame)
            {
                mFrame = frame;
            }
         
            public static void main(String argv[])
            {
                Frame frame = new Frame("MenuBar label problems...");
                Applet tmp = new ChgLabel(frame);
                frame.add("Center", tmp);
                frame.setSize(300, 300);
                frame.show();
                tmp.start();
            }
         
         
            public void start()
            {
                mButton_Expand = new Button("Expand");
                mButton_Expand.addActionListener(this);
                add(mButton_Expand);
         
                mButton_Shrink = new Button("Shrink");
                mButton_Shrink.addActionListener(this);
                add(mButton_Shrink);
         
                mTopMenu = buildMenu();
                mFrame.setMenuBar(mTopMenu);
            }
         
         
            public MenuBar buildMenu()
            {
                MenuItem mMItem;
                MenuBar bar;
         
                bar = new MenuBar();
         
                mMItem = new MenuItem("Plain1");
                mMenu1 = new Menu("First");
                mMenu1.add(mMItem);
                bar.add(mMenu1);
         
                mMItem = new MenuItem("Plain2");
                mMenu2 = new Menu("Second");
                mMenu2.add(mMItem);
                bar.add(mMenu2);
         
                mMItem = new MenuItem("Plain3");
                mMenu3 = new Menu("Third");
                mMenu3.add(mMItem);
                bar.add(mMenu3);
         
                mMItem = new MenuItem("Plain4");
                mMenu4 = new Menu("Fourth");
                mMenu4.add(mMItem);
                bar.add(mMenu4);
         
                return bar;
            }
         
         
            public void actionPerformed(ActionEvent event)
            {
                if ( event.getSource() == mButton_Expand )
                {
                    mMenu1.setLabel("FirstLongMenu");
                    mMenu2.setLabel("SecondLongMenu");
                    mMenu3.setLabel("ThirdLongMenu");
                    mMenu4.setLabel("FourthLongMenu");
                }
                else if ( event.getSource() == mButton_Shrink )
                {
                    mMenu1.setLabel("First");
                    mMenu2.setLabel("Second");
                    mMenu3.setLabel("Third");
                    mMenu4.setLabel("Fourth");
                }
            }
        }

              mbronsonsunw Mike Bronson (Inactive)
              tyao Ting-Yun Ingrid Yao (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: