int beginPositionX = x - icon.getIconWidth() / 2; int beginPositionY = y - icon.getIconHeight() / 2; icon.paintIcon(c, g, beginPositionX, beginPositionY);
x -= icon.getIconWidth() / 2; y -= icon.getIconHeight() / 2;  if (x < 0) x = 0; if (y < 0) y = 0;  icon.paintIcon(c, g, x, y);
  protected void drawCentered(Component c, Graphics g, Icon icon, int x, int y)  {    int beginPositionX = x - icon.getIconWidth() / 2;    int beginPositionY = y - icon.getIconHeight() / 2;    icon.paintIcon(c, g, beginPositionX, beginPositionY);  }