@ShowcaseSource
@Override
public Widget onInitialize() {
// Create a new frame
String url = GWT.getModuleBaseURL();
final Frame frame = new Frame(url);
frame.setSize("700px", "300px");
frame.ensureDebugId("cwFrame");
// Create a form to set the location of the frame
final TextBox locationBox = new TextBox();
locationBox.setText(url);
Button setLocationButton = new Button(constants.cwFrameSetLocation());
HorizontalPanel optionsPanel = new HorizontalPanel();
optionsPanel.setSpacing(8);
optionsPanel.add(locationBox);
optionsPanel.add(setLocationButton);
// Change the location when the user clicks the button
setLocationButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
frame.setUrl(locationBox.getText());
}
});
// Change the location when the user presses enter
locationBox.addKeyDownHandler(new KeyDownHandler() {
public void onKeyDown(KeyDownEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
frame.setUrl(locationBox.getText());
}
}
});