@SuppressWarnings("UseJBColor")
  @Override
  public void paint(Graphics g, JComponent c) {
    if (!(c instanceof OnOffButton b)) return;

    Graphics2D g2 = (Graphics2D)g.create();

    try {
      Insets i = c.getInsets();
      Point origin = new Point((c.getWidth() - BUTTON_SIZE.width) / 2 + i.left,
                               (c.getHeight() - BUTTON_SIZE.height) / 2 + i.top);
      Rectangle outerRect = new Rectangle(origin, BUTTON_SIZE);

      // Background
      g2.setColor(new Color(0xadadad));
      g2.fill(outerRect);

      // Fill
      g2.setColor(b.isSelected() ? new Color(0x119bfe) : new Color(0xe3e3e3));

      Point location = new Point((b.isSelected() ? JBUIScale.scale(16) : JBUIScale.scale(1)) + origin.x, JBUIScale.scale(1) + origin.y);
      Rectangle innerRect = new Rectangle(location, TOGGLE_SIZE);
      g2.fill(innerRect);

      Rectangle textRect = new Rectangle();
      Rectangle iconRect = new Rectangle();

      Font f = c.getFont();
      FontMetrics fm = g.getFontMetrics();
      g.setFont(f);

      // Font color set through foreground because paintText uses it to set the graphics color
      b.setForeground(b.isSelected() ? Color.white : Color.black);

      // layout the text and icon
      String text = SwingUtilities.layoutCompoundLabel(
        c, fm, b.isSelected() ? b.getOnText() : b.getOffText(), null,
        b.getVerticalAlignment(), b.getHorizontalAlignment(),
        b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
        innerRect, iconRect, textRect,
        b.getText() == null ? 0 : b.getIconTextGap());

      // Draw the Text
      if (text != null && !text.isEmpty()) {
        View v = (View)c.getClientProperty(BasicHTML.propertyKey);
        if (v != null) {
          v.paint(g2, textRect);
        }
        else {
          paintText(g2, b, textRect, text);
        }
      }
    }
    finally {
      g2.dispose();
    }
  }
@SuppressWarnings("UseJBColor")
  @Override
  public void paint(Graphics g, JComponent c)