void (Container parent) { int width = parent.getWidth(); int height = 0; for (Component component : parent.getComponents()) { if (component instanceof PaletteGroupComponent groupComponent) { groupComponent.setLocation(0, height); if (groupComponent.isVisible()) { int groupHeight = groupComponent.getPreferredSize().height; groupComponent.setSize(width, groupHeight); height += groupHeight; } else { groupComponent.setSize(0, 0); } if (groupComponent.isSelected() || !groupComponent.isVisible()) { PaletteItemsComponent itemsComponent = groupComponent.getItemsComponent(); int itemsHeight = itemsComponent.getPreferredSize().height; itemsComponent.setBounds(0, height, width, itemsHeight); height += itemsHeight; } } } }