# How to center a new window

**URL:** <https://forum.inductiveautomation.com/t/how-to-center-a-new-window/1996>\
**Category:** Archived Topics\
**Created:** [July 1, 2010, 8:35am UTC](https://forum.inductiveautomation.com/t/how-to-center-a-new-window/1996 "2010-07-01T08:35:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluefrog](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@bluefrog](https://forum.inductiveautomation.com/u/bluefrog)\
**Post date:** [July 1, 2010, 8:35am UTC](https://forum.inductiveautomation.com/t/how-to-center-a-new-window/1996/1 "2010-07-01T08:35:19Z")

</div>

Dear All,

I also got another little problem. ☹  
It’s that I want to open a window and place it at the center of the screen when user clicks the menu.  
Let’s say I want to open a window named Sample. I tried it like that  
So I place the following code for that menu in the menu editor.  
fpmi.nav.openWindow(“Sample”)  
fpmi.nav.centerWindow(“Sample”)  
But When I test it, It doesn’t show at the center. And another problem is that I have to click the menu twice to show that window in center. I want it to show at the center of the screen at the first time user click the menu. I hope someone help me.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [July 1, 2010, 3:18pm UTC](https://forum.inductiveautomation.com/t/how-to-center-a-new-window/1996/2 "2010-07-01T15:18:18Z")

</div>

The fpmi.nav.centerWindow function will center a window over a main window. This requires that another window is opened and maximized. You are also probably using the mouseClicked event, so if you change that to the mousePressed or mouseReleased you won’t have to click twice.
