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

Replacing menuBar associated with a Frame causes the frame position to change

XMLWordPrintable

    • generic
    • solaris_2.5.1

       Replacing the menuBar associated with a Frame causes the Frame's position
      to change - this problem doesn't occur under Win32 in 1.1FCS or 1.1.1Beta.
       
      To reproduce, run the testcase below, and click repeatedly on the button...
       
      import java.applet.*;
      import java.awt.*;
      import java.awt.event.*;
      import java.io.*;
       
      public class Movement extends Applet
          implements ActionListener
      {
          Button mButton;
          TextField mTextFld;
          Frame mFrame;
          MenuItem mMItem;
          Menu mSubMenu;
          MenuBar mTopMenu;
       
          public Movement(Frame frame)
          {
              mFrame = frame;
          }
       
          public static void main(String argv[])
          {
              Frame frame = new Frame("Menu movement problems...");
              Applet tmp = new Movement(frame);
              frame.add(tmp, "Center");
              frame.setSize(300, 300);
              frame.show();
              tmp.start();
          }
       
       
          public void start()
          {
              mButton = new Button("New Menu");
              mButton.addActionListener(this);
              add(mButton);
       
              mTextFld = new TextField("Visible");
              add(mTextFld);
       
              mMItem = new MenuItem("Plain Item");
              mMItem.addActionListener(this);
       
              mSubMenu = new Menu("SubMenu");
              mSubMenu.add(mMItem);
       
              mTopMenu = new MenuBar();
              mTopMenu.add(mSubMenu);
       
              mFrame.setMenuBar(mTopMenu);
          }
       
          public void actionPerformed(ActionEvent event)
          {
              if ( event.getSource() == mMItem )
              {
                  System.out.println("Plain Item handled.");
                  Toolkit.getDefaultToolkit().beep();
              }
              else if ( event.getSource() == mButton )
              {
                  mFrame.setMenuBar(null);
                  mFrame.setMenuBar(mTopMenu);
              }
          }
      }
       

            Unassigned Unassigned
            rschiavisunw Richard Schiavi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: