-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.4.0
-
sparc
-
solaris_2.6
Name: ooR10001 Date: 11/13/2000
Method revalidate() in class javax.swing.JComponent is not called automatically when
size or location of the component is changed. The following test showing this bug:
--------------------------------------
import javax.swing.JButton;
import javax.swing.JFrame;
class JRStub extends JButton {
boolean revalidateCalled = false;
public JRStub() {
super();
}
public synchronized void revalidate() {
super.revalidate();
revalidateCalled = true;
notifyAll();
}
public synchronized void waitValidate() {
try {
wait(5000);
} catch (InterruptedException ie) {
}
}
public void resetValidate() {
revalidateCalled = false;
}
}
public class t {
public static void main(String[] args) {
JFrame f = new JFrame();
JRStub c = new JRStub();
f.getContentPane().add(c);
f.setVisible(true);
c.waitValidate();
c.resetValidate();
c.setSize(new java.awt.Dimension(c.getSize().width + 1,
c.getSize().height + 1));
c.waitValidate();
if (!c.revalidateCalled) {
System.out.println("revalidate() is not called when the size"
+ " of component is changed");
}
c.resetValidate();
c.setLocation(c.getLocation().x + 1, c.getLocation().y);
c.waitValidate();
if (!c.revalidateCalled) {
System.out.println("revalidate() is not called when the location"
+ " of component is changed");
}
f.dispose();
}
}
-----------------------------------------
Test's output:
------------------------------
revalidate() is not called when the size of component is changed
revalidate() is not called when the location of component is changed
------------------------------
The javadoc says:
-----------------------------------------
revalidate
public void revalidate()
Supports deferred automatic layout.
..................................................
This method will automatically be called on this component when a property
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
value changes such that size, location, or internal layout of this component has
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
been affected. This automatic updating differs from the AWT because programs
^^^^^^^^^^^^^^
generally no longer need to invoke validate to get the contents of the GUI to update.
-----------------------------------------
The implementation needs to be fixed for matching the spec.
======================================================================