Graphics2D g2 = (Graphics2D) g; Stroke saved_stroke = g2.getStroke(); Color saved_color = g2.getColor(); float dashes[] = new float[] {1.0f, 1.0f}; BasicStroke s = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10, dashes, 0.0f); g2.setStroke(s); g2.setColor(Color.BLACK); g2.drawRect(vr.x + 2, vr.y + 2, vr.width - 4, vr.height - 4); g2.setStroke(saved_stroke); g2.setColor(saved_color);
Color saved_color = g.getColor(); g.setColor(focusColor); Rectangle focusRect = ir.union(tr); g.drawRect(focusRect.x, focusRect.y, focusRect.width, focusRect.height); g.setColor(saved_color);
  protected void paintFocus(Graphics g, AbstractButton b, Rectangle vr,                            Rectangle tr, Rectangle ir)  {    if (b.hasFocus() && b.isFocusPainted())      {        Graphics2D g2 = (Graphics2D) g;        Stroke saved_stroke = g2.getStroke();        Color saved_color = g2.getColor();        float dashes[] = new float[] {1.0f, 1.0f};                BasicStroke s = new BasicStroke(1.0f,                                         BasicStroke.CAP_SQUARE,                                         BasicStroke.JOIN_MITER,                                        10, dashes, 0.0f);        g2.setStroke(s);        g2.setColor(Color.BLACK);        g2.drawRect(vr.x + 2,                     vr.y + 2,                     vr.width - 4,                    vr.height - 4);        g2.setStroke(saved_stroke);        g2.setColor(saved_color);      }  }