int layer = getLayer (c); int[] range = layerToRange(new Integer(layer)); if (range[0] == range[1]) throw new IllegalArgumentException ();  int top = range[0]; int bot = range[1]; if (position == -1) position = (bot - top) - 1; int targ = Math.min(top + position, bot-1); int curr = -1;  Component[] comps = getComponents(); for (int i = top; i < bot; ++i) { if (comps[i] == c) { curr = i; break; } } if (curr == -1)  throw new IllegalArgumentException();  if (curr == 0) super.swapComponents(curr, targ); else while (curr > 0) super.swapComponents (curr, --curr);  revalidate(); repaint();
int layer = getLayer(c); int index = insertIndexForLayer(layer, position); setComponentZOrder(c, index);
  public void setPosition(Component c, int position)  {    int layer = getLayer (c);    int[] range = layerToRange(new Integer(layer));    if (range[0] == range[1])      throw new IllegalArgumentException ();    int top = range[0];    int bot = range[1];    if (position == -1)      position = (bot - top) - 1;    int targ = Math.min(top + position, bot-1);    int curr = -1;    Component[] comps = getComponents();    for (int i = top; i < bot; ++i)      {        if (comps[i] == c)          {            curr = i;            break;          }      }    if (curr == -1)      // should have found it      throw new IllegalArgumentException();    if (curr == 0)      super.swapComponents(curr, targ);    else      while (curr > 0)        super.swapComponents (curr, --curr);        revalidate();    repaint();  }