void (final Graphics g, final JComponent c) { Graphics2D g2 = (Graphics2D) g.create(); try { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //noinspection unchecked B button = (B) c; int width = button.getWidth(); int height = button.getHeight(); int arcSize = getArcSize(); if (c.isOpaque()) { g2.setColor(c.getBackground()); g2.fill(new Rectangle(c.getSize())); } Shape outerShape = new RoundRectangle2D.Float(0, 0, width, height, arcSize, arcSize); ButtonModel model = button.getModel(); if (model.isSelected()) { g2.setColor(getSelectionColor(button)); } else if (model.isRollover()) { g2.setColor(getRolloverColor(button)); } else { Color bg = getBackgroundColor(button); if (bg != null) { g2.setColor(bg); } } g2.fill(outerShape); Color borderColor = button.hasFocus() ? getFocusColor(button) : getUnfocusedBorderColor(button); if (borderColor != null) { g2.setColor(borderColor); Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD); border.append(outerShape, false); border.append(new RoundRectangle2D.Float(BW.get(), BW.get(), width - BW.get() * 2, height - BW.get() * 2, arcSize - BW.get(), arcSize - BW.get()), false); g2.fill(border); } } finally { g2.dispose(); } super.paint(g, c); }