-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
1.4.0, 1.4.2
-
generic, x86
-
generic, windows_2000
Name: gm110360 Date: 04/26/2004
FULL PRODUCT VERSION :
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)
Same bug in
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)jdk 1.4.2
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
JScrollPane calculates a too small minimum size, if the horizontal scrollbar is active.
It seems, that the method miniumSize() is used for the scroll panes children, instead of getMinimumSize(). As you might know, the deprecated method minimumSize() returns 1 for JLabel and probably some other Swing components.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and execute the source code provided:
Frame (BorderLayout)
JScrollPane (North)
JLabel
JLabel (Center)
Resize the window to allow the scroll pane to display with or without horizontal scroll bar.
It is also possible to produce this result using a GridBagLayout instead of a BorderLayout: Use yWeight =0 for the scroll pane and yWeight=1 for the bottom label.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both labels should always be visible (unless the window is very tiny). The scroll pane should always be as small as possible.
ACTUAL -
When the scrollbar is inactive, everything is fine.
When the scrollbar activet due to resizing, it is still fine.
After a second resize (scrollbar still active), the top label is no more visible (height of only one pixel).
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
/*
* Test class to demonstrated buggy behaviour of JScrollPane.
* Created on 26. April 2004, 19:50
* @author Bernhard Seebass / ###@###.###
*/
public class BugTest extends JFrame {
public BugTest() {
JScrollPane jScrollPane1 = new JScrollPane();
jScrollPane1.setViewportView(new JLabel("++++++++++++ Scroll Pane Content ++++++++++++"));
getContentPane().add(jScrollPane1, java.awt.BorderLayout.NORTH);
getContentPane().add(new JLabel("Center Content"), java.awt.BorderLayout.CENTER);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setSize(200,200);
}
public static void main(String args[]) {
new BugTest().show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
don't use horizontal scroll bars, if the vertical size is not fixed from outside :(
(Incident Review ID: 259883)
======================================================================
FULL PRODUCT VERSION :
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)
Same bug in
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)jdk 1.4.2
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
JScrollPane calculates a too small minimum size, if the horizontal scrollbar is active.
It seems, that the method miniumSize() is used for the scroll panes children, instead of getMinimumSize(). As you might know, the deprecated method minimumSize() returns 1 for JLabel and probably some other Swing components.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and execute the source code provided:
Frame (BorderLayout)
JScrollPane (North)
JLabel
JLabel (Center)
Resize the window to allow the scroll pane to display with or without horizontal scroll bar.
It is also possible to produce this result using a GridBagLayout instead of a BorderLayout: Use yWeight =0 for the scroll pane and yWeight=1 for the bottom label.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both labels should always be visible (unless the window is very tiny). The scroll pane should always be as small as possible.
ACTUAL -
When the scrollbar is inactive, everything is fine.
When the scrollbar activet due to resizing, it is still fine.
After a second resize (scrollbar still active), the top label is no more visible (height of only one pixel).
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
/*
* Test class to demonstrated buggy behaviour of JScrollPane.
* Created on 26. April 2004, 19:50
* @author Bernhard Seebass / ###@###.###
*/
public class BugTest extends JFrame {
public BugTest() {
JScrollPane jScrollPane1 = new JScrollPane();
jScrollPane1.setViewportView(new JLabel("++++++++++++ Scroll Pane Content ++++++++++++"));
getContentPane().add(jScrollPane1, java.awt.BorderLayout.NORTH);
getContentPane().add(new JLabel("Center Content"), java.awt.BorderLayout.CENTER);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setSize(200,200);
}
public static void main(String args[]) {
new BugTest().show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
don't use horizontal scroll bars, if the vertical size is not fixed from outside :(
(Incident Review ID: 259883)
======================================================================