Moving a Nifty Window from java code (and getting x and y coords)

Hi to everybody.

I’m trying to move a nifty window from java but i’m stucked :frowning:

I’ve defined my window in this way inside the xml:

<control id=“win” name=“window” title=“You can drag me around…” width=“500px” height=“400px” x="${CALL.getX()}px" y="${CALL.getY()}px">
<text text="${CALL.getX()} this is the x position" style=“base-font” color="#eeef" valign=“center” width=“100%” />

and the getX and getY method returns the start window position.
Now i want to make the windows move, i.e. when i click with the mouse to the current cursor position

but how?
I’ve located the Window object in this whay

[java]Window w = screen.findNiftyControl(“win”, Window.class);[/java]

and it works, but the object w has no method to set and get the position of the window.

Any idea?

Thank you

I’ve found the solution, and i want to share with you.

It’s a bit cumbersome, i don’t know if it’s the best way to do it, anyway…


    Element windows = screen.findElementByName("win");
    SizeValue xx = new SizeValue(new Integer(x.intValue()).toString());
    SizeValue yy = new SizeValue(new Integer(screenHeight-y.intValue()).toString());



1 Like