Java/GWT/Widget
Версия от 18:01, 31 мая 2010; (обсуждение)
Get Widget Absolute Position
package com.jexp.gwt.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.HTML;
public class GWTClient implements EntryPoint {
public void onModuleLoad() {
Button b = new Button("Click me", new ClickListener() {
public void onClick(Widget sender) {
MyPopup p = new MyPopup();
int left = sender.getAbsoluteLeft() + 10;
int top = sender.getAbsoluteTop() + 10;
p.setPopupPosition(left, top);
p.show();
}
});
RootPanel.get().add(b);
}
}
class MyPopup extends PopupPanel {
public MyPopup() {
super(true);
HTML contents = new HTML("Click anywhere outside this popup to make it disappear.");
contents.setWidth("128px");
setWidget(contents);
setStyleName("popups-Popup");
}
}