-
Bug
-
Resolution: Fixed
-
P4
-
5.0u6
-
b11
-
sparc
-
solaris_2.5.1
The javadoc contract for JComponent.setMinimumSize(Dimension) states:
"Sets the minimum size of this component to a constant value. Subsequent calls to getMinimumSize will always return this value..."
However, JScrollBar overrides getMinimumSize() and breaks this contract - it always returns a minimum size derived from the preferred size even if you have previously called setMinimumSize().
Code to reproduce:
JScrollBar bar = new JScrollBar( SwingConstants.HORIZONTAL );
bar.setMinimumSize( new Dimension( 75, 0 ) );
System.out.println( bar.getMinimumSize() );
Expected: Prints "java.awt.Dimension[width=75,height=0]"
Actual: Prints "java.awt.Dimension[width=5,height=17]"
The code for JScrollBar.java contains this comment above the implementation of getMinimumSize():
// PENDING(hmuller) - the next three methods should be removed
Indeed, removing those three methods would fix this bug.
"Sets the minimum size of this component to a constant value. Subsequent calls to getMinimumSize will always return this value..."
However, JScrollBar overrides getMinimumSize() and breaks this contract - it always returns a minimum size derived from the preferred size even if you have previously called setMinimumSize().
Code to reproduce:
JScrollBar bar = new JScrollBar( SwingConstants.HORIZONTAL );
bar.setMinimumSize( new Dimension( 75, 0 ) );
System.out.println( bar.getMinimumSize() );
Expected: Prints "java.awt.Dimension[width=75,height=0]"
Actual: Prints "java.awt.Dimension[width=5,height=17]"
The code for JScrollBar.java contains this comment above the implementation of getMinimumSize():
// PENDING(hmuller) - the next three methods should be removed
Indeed, removing those three methods would fix this bug.
- csr for
-
JDK-8317857 JScrollBar.getMinimumSize() breaks the contract of JComponent.setMinimumSize()
- Closed