/** * Returns the corner that contains the point <code>x</code>, <code>y</code>, or -1 if the * position doesn't match a corner. */ private int calculateCorner(Window w, int x, int y) { Insets insets = w.getInsets(); int xPosition = calculatePosition(x - insets.left, w.getWidth() - insets.left - insets.right); int yPosition = calculatePosition(y - insets.top, w.getHeight() - insets.top - insets.bottom); if (xPosition == -1 || yPosition == -1) { return -1; } return yPosition * 5 + xPosition; }