// add window resize listener
Window w = SwingUtilities.getWindowAncestor(this);
if (w != null) {
w.addComponentListener(componentAdapter);
} else {
addAncestorListener(new AncestorListener() {
public void ancestorAdded(AncestorEvent event) {
Window w = SwingUtilities.getWindowAncestor(
SingleComponentInfiniteProgress.this);
if (w != null) {
w.addComponentListener(componentAdapter);