void (Graphics g) { 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); int bw = JBUIScale.scale(1); ButtonModel bm = getModel(); // set clip Area clip = new Area(g2.getClip()); if (!bm.isRollover() && !bm.isPressed()) { clip.subtract(new Area(new Rectangle2D.Double(0, 0, bw, getHeight()))); } if (getDirection() == SwingConstants.NORTH && prevButton.getModel().isRollover()) { clip.subtract(new Area(new Rectangle(0, getHeight() - bw, getWidth() - bw, bw))); } else if (getDirection() == SwingConstants.SOUTH && nextButton.getModel().isRollover()) { clip.subtract(new Area(new Rectangle(0, 0, getWidth() - bw, bw))); } g2.setClip(clip); // paint background Rectangle outerRect = new Rectangle(0, getDirection() == SwingConstants.NORTH ? bw : 0, getWidth() - bw, getHeight() - bw); if (spinner.isEnabled()) { if (bm.isPressed()) { g2.setColor(UIManager.getColor("Button.intellij.native.pressedBackgroundColor")); } else if (bm.isRollover()) { g2.setColor(UIManager.getColor("Button.intellij.native.focusedBackgroundColor")); } else { g2.setColor(UIManager.getColor("Button.background")); } } else { g2.setColor(UIManager.getColor("Button.background")); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.47f)); } g2.fill(outerRect); // paint icon Icon icon = WinIconLookup.getIcon(iconName, false, false, isEnabled()); icon.paintIcon(this, g2, JBUIScale.scale(5), JBUIScale.scale(3)); // paint border if (spinner.isEnabled()) { if (bm.isPressed()) { g2.setColor(UIManager.getColor("Button.intellij.native.pressedBorderColor")); } else if (bm.isRollover()) { g2.setColor(UIManager.getColor("Button.intellij.native.focusedBorderColor")); } else { g2.setColor(UIManager.getColor("Button.intellij.native.borderColor")); } } else { g2.setColor(UIManager.getColor("Button.intellij.native.borderColor")); } Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD); border.append(outerRect, false); Rectangle innerRect = new Rectangle(outerRect); JBInsets.removeFrom(innerRect, JBUI.insets(1)); border.append(innerRect, false); g2.fill(border); } finally { g2.dispose(); } }