I know this is a tad offtopic for JGO, so I posted it in this section.
When trying to debug my AWT / layoutmanager code, I stumbled into this sourcecode of java.awt.Component:
public void invalidate() {
synchronized (getTreeLock()) {
/* Nullify cached layout and size information.
* For efficiency, propagate invalidate() upwards only if
* some other component hasn't already done so first.
*/
valid = false;
if (!isPreferredSizeSet()) {
prefSize = null;
}
if (!isMinimumSizeSet()) {
minSize = null;
}
if (!isMaximumSizeSet()) {
maxSize = null;
}
if (parent != null && parent.valid) {
parent.invalidate();
}
}
}
What this does:
if (!isPreferredSizeSet()) {
prefSize = null;
}
is basicly:
if(prefSize==null) prefSize = null;
Obviously it should have been: if (isPreferredSizeSet()) (without the “!”)
because of this the invalidate() method is not working properly, as it does NOT reset the cached values for prefSize/minSize/maxSize.
Did I miss something, or did I find a bug… (created in Java 1.5, as isPreferedSizeSet() is a 1.5 method)