如何在gxt中获取窗口的x y位置

时间:2017-02-28 06:18:24

标签: java gwt window gxt

如何在GXT中获取窗口的X Y位置?我可以使用setPosition设置位置。但由于没有get方法,我无法获得该位置。你能帮我检查一下窗户的位置吗?

Window window = new Window();
window.setClosable(true);
window.setWidth(300);
window.setHeight(300);
window.setPosition(30, 50);

1 个答案:

答案 0 :(得分:0)

对于GWT中的每个元素,你可以得到元素的位置:

/**
 * Gets the object's absolute left position in pixels, as measured from the
 * browser window's client area.
 * 
 * @return the object's absolute left position
 */
window.getAbsoluteLeft();

/**
 * Gets the object's absolute top position in pixels, as measured from the
 * browser window's client area.
 * 
 * @return the object's absolute top position
 */
window.getAbsoluteTop();

这两个方法都是GWT中UiObject类的一部分,GWT 2中的每个小部件都继承该方法。

希望有所帮助。