void (Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D)g.create(); try { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); Rectangle r = new Rectangle(c.getWidth(), c.getHeight()); Container parent = c.getParent(); if (c.isOpaque() && parent != null) { g2.setColor(parent.getBackground()); g2.fill(r); } JBInsets.removeFrom(r, JBUI.insets(1, 1, 1, BUTTON_WIDTH)); JBInsets.removeFrom(r, c.getInsets()); g2.setColor(c.isEnabled() ? c.getBackground() : UIManager.getColor("Button.background")); if (!c.isEnabled()) { g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.35f)); } g2.fill(r); } finally { g2.dispose(); } }