-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
sparc
-
solaris_2.6
Name: ooR10001 Date: 06/18/2001
javax.swing.SpringLayout.getConstraints(Component c) method does not match the
specification because it does not check "constraints" client property of the
component c if c is instance of JComponent and no constraints has been
registered for this component. It contradicts with current JavaDoc.
Javadoc says:
-------------------------------------------
getConstraints
public SpringLayout.Constraints getConstraints(Component c)
Returns the constraints for the specified component. Note that, unlike
the GridBagLayout, constraints are not cloned by this method. If no
^^^^^
constraint has been registered for this component and the component is a
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
JComponent, this method checks the "constraints" client property of the
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
component.
^^^^^^^^^^
...............
-------------------------------------------
This test shows a bug:
----------- test.java ------------
import javax.swing.JComponent;
import javax.swing.SpringLayout;
import javax.swing.SpringLayout.Constraints;
import javax.swing.JButton;
class Stub extends SpringLayout.Constraints {
}
public class test {
public static void main(String[] args) {
JComponent comp = new JButton();
SpringLayout sp = new SpringLayout();
Stub stub = new Stub();
comp.putClientProperty("constraints", stub);
if (sp.getConstraints(comp) instanceof Stub) {
System.out.println("OKAY");
} else {
System.out.println("FAILED");
}
}
}
----------------------------------
Output:
-----------------------------
% java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
% java test
FAILED
-----------------------------
======================================================================