Dimension (Container parent) { int height = 0; int count = parent.getComponentCount(); int lines = 0; myMiddleLineHeight = 0; for (int i = 0; i < count; i++) { Component component = parent.getComponent(i); if (component instanceof AnimatedIcon) { continue; } int lineHeight = component.getPreferredSize().height; height += lineHeight; if (component instanceof ListPluginComponent) { myMiddleLineHeight += lineHeight; lines++; } } calculateLineHeight(lines); int size = ((PluginsGroupComponent)parent).getGroups().size(); if (size > 1) { height += myGroupGap.get() * (size - 1); } return new Dimension(0, height); }