Thanks,
Eric
add your content and then try following solution based on GWT docs:
package com.mycompany.project.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.DialogBox;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class TestDialog implements EntryPoint {
private Button clickMeButton;
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
clickMeButton = new Button("Open sample dialog");
clickMeButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
// show example dialog
new ExampleDialog();
}
});
rootPanel.add(clickMeButton);
}
class ExampleDialog extends DialogBox {
public ExampleDialog() {
setText("Example dialog text");
final Button closeBtn = new Button("CLOSE");
closeBtn.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
hide();
}
});
setWidget(closeBtn);
// show and center
setPopupPositionAndShow(new PopupPanel.PositionCallback() {
public void setPosition(int offsetWidth, int offsetHeight) {
int left = ((Window.getClientWidth() - offsetWidth) / 2) >> 0;
int top = ((Window.getClientHeight() - offsetHeight) / 2) >> 0;
setPopupPosition(left, top);
}
});
}
}
}
regards,
Peter
why not new ExampleDialog().center()?
- Filipe Sousa
However, I only want to center the dialog horizontally, not
vertically, so Peter's suggestion is what I'll continue to use. I
think center() will work for a lot of other people though.
Thanks,
Eric
-> centered horizontally but not vertically
On Sep 2, 7:35 pm, Eric B <ebesse...@gmail.com> wrote:
> Filipe,
> Wow, you're right, there is a center() method too.http://code.google.com/webtoolkit/documentation/com.google.gwt.user.c...()
On Sep 2, 9:55 pm, Axel Kittenberger <axe...@gmail.com> wrote:
> get top position
> center()
> set top position
there will be flickrering with that multistep positioning I think,
I've used code recommended to avoid flickering simply,
regards,
peter