Rectangle (List<? extends Icon> icons, JComponent c, Graphics g, Rectangle bounds, int gapBetweenIcons) { if (icons.isEmpty()) return new Rectangle(); int maxHeight = 0; int shift = 0; for (Icon icon : icons) { if (shift != 0) shift += gapBetweenIcons; int x = bounds.x + shift; int y = bounds.y + bounds.height / 2 - icon.getIconHeight() / 2; icon.paintIcon(c, g, x, y); shift += icon.getIconWidth(); maxHeight = Math.max(maxHeight, icon.getIconHeight()); } return new Rectangle(shift, maxHeight); }