# Need help accurately positioning form in dialog

**URL:** <https://forum.servoy.com/t/need-help-accurately-positioning-form-in-dialog/5172>\
**Category:** Classic Servoy\
**Created:** [December 7, 2005, 12:02am UTC](https://forum.servoy.com/t/need-help-accurately-positioning-form-in-dialog/5172 "2005-12-07T00:02:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveInLA](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@SteveInLA](https://forum.servoy.com/u/SteveInLA)\
**Post date:** [December 7, 2005, 12:02am UTC](https://forum.servoy.com/t/need-help-accurately-positioning-form-in-dialog/5172/1 "2005-12-07T00:02:54Z")

</div>

I am trying to show a formInDialog in a particular place on the screen based on the location of element. I can account for the window position of the main window in case the user has moved the window, and I can add the width of my controller to the X position, but the presence or non-presence of toolbars is messing up my Y position.

Is there some way to get the screen location of an element, not just its form location?

Steve in LA

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [December 9, 2005, 1:32pm UTC](https://forum.servoy.com/t/need-help-accurately-positioning-form-in-dialog/5172/2 "2005-12-09T13:32:41Z")

</div>

Lets do some advanced stuf ![:)]( "Smile")

var x = elements.test.getLocationX();  
var y = elements.test.getLocationY();  
var point = new java.awt.Point(x,y);  
Packages.javax.swing.SwingUtilities.convertPointToScreen(point,elements.test);

---

<div class="post-metadata">

**Author:** ![SteveInLA](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@SteveInLA](https://forum.servoy.com/u/SteveInLA)\
**Post date:** [December 12, 2005, 6:19pm UTC](https://forum.servoy.com/t/need-help-accurately-positioning-form-in-dialog/5172/3 "2005-12-12T18:19:18Z")

</div>

Too advanced for me. I’ll have to become much more fluent in Java before things like this make sense to me. No worries, though since I already found a way around my immediate problem.

Thanks.

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [December 13, 2005, 6:39am UTC](https://forum.servoy.com/t/need-help-accurately-positioning-form-in-dialog/5172/4 "2005-12-13T06:39:18Z")

</div>

Added

- getScreenX(element) and
- getScreenY(element)

to the tools plugin. Will be available later this week ![:)]( "Smile")

you can do this:

//calculate the new x coordinate of the dialog  
var x = plugins.it2be\_tools.getScreenX(elements.button) - elements.button.getLocationX();

//calculate the new y coordinate of the dialog  
var y = plugins.it2be\_tools.getScreenY(elements.button) + elements.button.getHeight() - elements.button.getLocationY();

application.showFormInDialog( forms.test2, x, y, -1, -1, ‘Test’, false,false,true);

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [December 13, 2005, 3:44pm UTC](https://forum.servoy.com/t/need-help-accurately-positioning-form-in-dialog/5172/5 "2005-12-13T15:44:46Z")

</div>

Marcel - AWESOME!

Johan - THANKS - very cool!

---

<div class="post-metadata">

**Author:** ![SteveInLA](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@SteveInLA](https://forum.servoy.com/u/SteveInLA)\
**Post date:** [December 20, 2005, 10:47pm UTC](https://forum.servoy.com/t/need-help-accurately-positioning-form-in-dialog/5172/6 "2005-12-20T22:47:09Z")

</div>

Marcel == The Man!

Thank you very much. Your feature worked like a charm.

Steve in LA

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [December 21, 2005, 9:17am UTC](https://forum.servoy.com/t/need-help-accurately-positioning-form-in-dialog/5172/7 "2005-12-21T09:17:29Z")

</div>

Thanks for the compliment

BTW when you say this you are checking if I am The Man ![;)]( "Wink")

> Marcel == The Man!

Not sure yet  
 ![:D]( "Very Happy")
