|
Quick Lists
|
|
Bug ID:
|
6721088
|
|
Votes
|
1
|
|
Synopsis
|
Bad window size calculation after using pack()
|
|
Category
|
java:classes_awt
|
|
Reported Against
|
|
|
Release Fixed
|
7(b48)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
|
|
Submit Date
|
01-JUL-2008
|
|
Description
|
FULL PRODUCT VERSION :
openjdk version "1.6.0-internal"
OpenJDK Runtime Environment (build 1.6.0-internal-langel_02_jun_2008_10_58-b00)
OpenJDK Server VM (build 10.0-b19, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux towel.yyz. customer .com 2.6.25-14.fc9.i686 #1 SMP Thu May 1 06:28:41 EDT 2008 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The pack() method of the Window class allow to resize the window based on the
contents preferred sizes, when using OpenJDK on the following example, the
window always have a empty area below (that does not happens of the Sun Java
binaries)
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
public class TestFrame {
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel(new FlowLayout());
panel.add(new JButton("Testing..."));
frame.setContentPane(panel);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the test case
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Window should be framed around the center button
ACTUAL -
Window is longer than it should be. size calculated wrong
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
public class TestFrame {
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel(new FlowLayout());
panel.add(new JButton("Testing..."));
frame.setContentPane(panel);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
---------- END SOURCE ----------
Posted Date : 2008-07-01 05:40:05.0
|
|
Work Around
|
N/A
|
|
Evaluation
|
In Windows it is impossible to make an application window smaller then a certain size,
so for this case, pack() sets the smallest possible width of the window
(you can't make it smaller with the mouse)
closed as not a but
Posted Date : 2008-07-14 15:01:17.0
The described problem is really a bug in AWT, so CR is reopened.
Posted Date : 2009-01-19 11:28:54.0
The bug seems to be in XDecoratedPeer.reshape(WindowDimensions, int, boolean) method. When userReshape is true (that is, this is a programmatic reshape request), the following code is executed:
Rectangle reqBounds = newDimensions.getBounds();
Rectangle newBounds = constrainBounds(reqBounds.x, reqBounds.y, reqBounds.width, reqBounds.height);
newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet());
reqBounds is always the whole window bounds including insets. newBounds is only not equal to reqBounds for constrained windows (shown by untrusted applets) because of security warning banner - not for the given test. And the third line is incorrect: indeed, if newDimensions.isClientSet is true (e.g. when pack() is called) the constructed WindowDimensions object has newBounds equal to its client bounds, which is wrong as newBounds is always a full bounds including insets. That's why it would be correct to pass 'false' instead of newDimensions.isClientSizeSet() or handle the client size separately (subtract current insets from newBounds). The second approach is listed in Suggested Fix.
Posted Date : 2009-01-19 11:28:54.0
|
|
Comments
|
Submitted On 15-JUL-2008
robmv
I am the original submitter of the bug on Red Hat bugzilla, and please take a look at the new attached image on that bug report
https://bugzilla.redhat.com/attachment.cgi?id=311852
It shows the minimum size of a window on Windows, and a JFrame shown on Linux with the problem, as you notice the smallest window size has nothing to do with the bad pack() behaviour. there final size using OpenJDK 6 is bigger that the one using Sun JDK 6
Submitted On 15-OCT-2008
rover0
I am suffering the same issue. You can see in the link below a snapshot of the same application (OpenJDK 6 at the left, Sun JDK 6 at the right).
http://rover.thehackers.org/geotrans/openjdk6-sunjava6.png
Submitted On 23-FEB-2009
This has been applied in b48 of OpenJDK7, so fix is now delivered.
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |