void (final Component component) { final ComponentListener listener = new ComponentListener() { @Override public void componentResized(ComponentEvent e) { impl(); } private void impl() { if (canExecute()) { if (init()) { component.removeComponentListener(this); myIsAdjusted = true; } } } @Override public void componentMoved(ComponentEvent e) { } @Override public void componentShown(ComponentEvent e) { impl(); } @Override public void componentHidden(ComponentEvent e) { } }; component.addComponentListener(listener); }