void (@NotNull SimpleColoredComponent component, @NotNull Graphics g, @NotNull Rectangle bounds) { Graphics2D g2 = (Graphics2D)g.create(bounds.x, bounds.y, bounds.width, bounds.height); try { component.setBounds(0, 0, bounds.width, bounds.height); component.paint(g2); } finally { g2.dispose(); } }