boolean[] (final Rectangle layeredBounds, final Rectangle frameBounds) { boolean x = frameBounds.getMaxX() < layeredBounds.x || layeredBounds.getMaxX() < frameBounds.x; boolean y = frameBounds.getMaxY() < layeredBounds.y || layeredBounds.getMaxY() < frameBounds.y; if (x || y) { return new boolean[] {x, y}; } else { return null; } }