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

setSize incorrect on Frame with Menubar

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.0
    • client-libs
    • beta
    • x86
    • windows_95



      Name: vi73552 Date: 06/01/99


      I tried the following code with
      1. JDK 1.1.5
      2. JDK 1.1.8
      3. JDK 1.2

      It displays a frame with two labels and one buttons.
      Start program with
      java SetSizeBug 200 200
      which should set the size of the frame to 200x200.

      When the menubar is not there, it works fine.
      Now with the menubar, when the Frame shows, press the button.#
      This will then display the actual size of the frame, which is now ...
      200x219 -- 19 Pixels to much.

      Source Code:

      import java.awt.*;
      import java.awt.event.*;

      class SetSizeBug extends Frame{
      public SetSizeBug(int width, int height){
      super("SetSizeBug");
      super.setSize(width, height);

      MenuBar menubar = new MenuBar();
      Menu menu = new Menu("Connection");

      menubar.add(menu);
      setMenuBar(menubar);

      setLayout(new GridLayout(3, 1));

      add(new Label("Size should be (" + width + ", " + height + ")."));

      final Label b;
      add(b = new Label("Size is (" + getSize().width + ", " + getSize().height + ")."));

      final Button dob = new Button("do");
      dob.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent evt){
      Dimension d = SetSizeBug.this.getSize();
      b.setText("Size is (" + d.width + ", " + d.height + ").");
      }
      });

      add(dob);
      }

      public static void main(String argv[]){
      SetSizeBug bug = new SetSizeBug(Integer.parseInt(argv[0]), Integer.parseInt(argv[1]));
      bug.setVisible(true);
      }
      }
      (Review ID: 83687)
      ======================================================================

            rraysunw Richard Ray (Inactive)
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: