@Override
public void paint(Graphics gr, JComponent c) {
final OnOffButton button = (OnOffButton)c;
final Dimension size = button.getSize();
int w = size.width-8;
int h = size.height-6;
int xOff = (myButton.getWidth() - w) / 2;
int yOff = (myButton.getHeight() - h) / 2;
g.translate(xOff, yOff);
if (button.isSelected()) {
g.setColor(new JBColor(new Color(74, 146, 73), new Color(77, 105, 76)));
g.fillRoundRect(0, 0, w, h, 5, 5);
g.fillRoundRect(w - h, 1, h, h-1, 3, 3);
g.setColor(UIUtil.getListForeground(true));
g.drawString(button.getOnText(), h/2, h - 4);
} else {
g.setColor(UIUtil.getPanelBackground());
g.drawRoundRect(0, 0, w, h, 5, 5);
g.setColor(UIUtil.getLabelDisabledForeground());
g.drawString(button.getOffText(), h + 4 , h - 4);
g.setColor(UIUtil.getBorderColor());
g.setPaint(new GradientPaint(h, 0, new JBColor(Gray._158, Gray._100), 0, h, new JBColor(Gray._210, Gray._100)));