Insets insets = frame.getInsets();
    private int sectionOfClick(int x, int y)    {      Insets insets = frame.getInsets();      Rectangle b = frame.getBounds();      if (x < insets.left && y < insets.top)        return NORTH_WEST;      else if (x > b.width - insets.right && y < insets.top)        return NORTH_EAST;      else if (x > b.width - insets.right && y > b.height - insets.bottom)        return SOUTH_EAST;      else if (x < insets.left && y > b.height - insets.bottom)        return SOUTH_WEST;      else if (y < insets.top)        return NORTH;      else if (x < insets.left)        return WEST;      else if (y > b.height - insets.bottom)        return SOUTH;      else if (x > b.width - insets.right)        return EAST;      return -1;    }