Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4243125
Votes 2
Synopsis setSize incorrect on Frame with Menubar
Category java:classes_awt
Reported Against 1.2
Release Fixed 1.4(merlin-beta)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 02-JUN-1999
Description




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) 
======================================================================
Work Around
On windows, account for the menu bar when adjusting the frame to the correct size.
  xxxxx@xxxxx   1999-08-02
Evaluation
Confirmed to still exist in 1.3.  This is a win32-only bug.

  xxxxx@xxxxx   1999-08-02
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang