---
title: center()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nswindow/center()
---

# center()

Sets the window’s location to the center of the screen.

## Declaration

```swift
func center()
```

## Discussion

Discussion The window is placed exactly in the center horizontally and somewhat above center vertically. Such a placement carries a certain visual immediacy and importance. This method doesn’t put the window onscreen, however; use makeKeyAndOrderFront(_:) to do that. You typically use this method to place a window—most likely an alert dialog—where the user can’t miss it. This method is invoked automatically when a panel is placed on the screen by the runModal(for:) method of the NSApplication class.

## See Also

### Moving Windows

- [isMovableByWindowBackground](appkit/nswindow/ismovablebywindowbackground.md)
- [isMovable](appkit/nswindow/ismovable.md)
