Rectangle clip = g.getClipBounds(); Rectangle tmp = new Rectangle();
  public void paint(Graphics g, Shape a)  {    Rectangle alloc;    if (a instanceof Rectangle)      alloc = (Rectangle) a;    else      alloc = a.getBounds();    int x = alloc.x + getLeftInset();    int y = alloc.y + getTopInset();    Rectangle clip = g.getClipBounds();    Rectangle tmp = new Rectangle();    int count = getViewCount();    for (int i = 0; i < count; ++i)      {        tmp.x = x + getOffset(X_AXIS, i);        tmp.y = y + getOffset(Y_AXIS, i);        tmp.width = getSpan(X_AXIS, i);        tmp.height = getSpan(Y_AXIS, i);        if (tmp.intersects(clip))          paintChild(g, tmp, i);      }  }