{ ButtonModel bmodel = null;  if (c instanceof AbstractButton) bmodel = ((AbstractButton) c).getModel();  Color darkShadow = MetalLookAndFeel.getControlDarkShadow(); Color shadow = MetalLookAndFeel.getControlShadow(); Color light = MetalLookAndFeel.getControlHighlight(); Color middle = MetalLookAndFeel.getControl();  if (c.isEnabled()) {  g.setColor(darkShadow); g.drawRect(x, y, w - 2, h - 2);  if (!bmodel.isPressed()) {  g.setColor(light); g.drawRect(x + 1, y + 1, w - 2, h - 2);   g.setColor(middle); g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2); g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1); } else {  g.setColor(light); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);   g.setColor(middle); g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2);   g.setColor(shadow); g.drawRect(x + 1, y + h - 2, 0, 0); g.drawRect(x + w - 2, y + 1, 0, 0); } } else {  g.setColor(MetalLookAndFeel.getInactiveControlTextColor()); g.drawRect(x, y, w - 2, h - 2); }
paintDefaultButtonBorder(c, g, x, y, w, h);
    public void paintBorder(Component c, Graphics g, int x, int y, int w,                            int h)    {      // With the OceanTheme the button border is painted entirely different.      // However, I couldn't figure out how this is determined besides checking      // for instanceof OceanTheme. The button painting is definitely not      // influenced by a UI default property and it is definitely performed      // by the same Border class.      if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme)        paintOceanButtonBorder(c, g, x, y, w, h);      else        {      ButtonModel bmodel = null;            if (c instanceof AbstractButton)        bmodel = ((AbstractButton) c).getModel();      Color darkShadow = MetalLookAndFeel.getControlDarkShadow();      Color shadow = MetalLookAndFeel.getControlShadow();          Color light = MetalLookAndFeel.getControlHighlight();      Color middle = MetalLookAndFeel.getControl();      if (c.isEnabled())      {        // draw dark border        g.setColor(darkShadow);        g.drawRect(x, y, w - 2, h - 2);        if (!bmodel.isPressed())          {            // draw light border            g.setColor(light);            g.drawRect(x + 1, y + 1, w - 2, h - 2);            // draw crossing pixels of both borders            g.setColor(middle);                  g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);                  g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);          }        else          {            // draw light border            g.setColor(light);            g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);            g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);            // draw shadow border            g.setColor(middle);            g.drawLine(x + 1, y + 1, x + w - 2, y + 1);            g.drawLine(x + 1, y + 1, x + 1, y + h - 2);             // draw crossing pixels of both borders            g.setColor(shadow);            g.drawRect(x + 1, y + h - 2, 0, 0);            g.drawRect(x + w - 2, y + 1, 0, 0);          }      }      else         {          // draw disabled border          g.setColor(MetalLookAndFeel.getInactiveControlTextColor());          g.drawRect(x, y, w - 2, h - 2);                  }    }    }