else { int x = c.getX(); int y = c.getY();  int cWidth = c.getWidth(); int cHeight = c.getHeight(); Dimension screenSize = getToolkit().getScreenSize();    if ((y + cHeight) > screenSize.height) {  if ((screenSize.width / 2 - x) <= 0) { if ((x - width) >= 0) x -= width; else x = 0; } else { if ((x + cWidth + width) <= screenSize.width) x += cWidth; else x = screenSize.width - width; }  y = screenSize.height - height; } else if (cWidth > width || cHeight > height) {  if ((x + width) > screenSize.width) x = screenSize.width - width;  else if (x < 0) x = 0; else x += (cWidth - width) / 2;  y += (cHeight - height) / 2; } else {  if ((x + width) > screenSize.width) x = screenSize.width - width;  else if (x < 0) x = 0; else x -= (width - cWidth) / 2;  y -= (height - cHeight) / 2; }  setLocation(x, y); }
  public void setLocationRelativeTo (Component c)  {    if (c == null || !c.isShowing ())      {        int x = 0;        int y = 0;        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment ();        Point center = ge.getCenterPoint ();        x = center.x - (width / 2);        y = center.y - (height / 2);        setLocation (x, y);      }    // FIXME: handle case where component is non-null.  }