FileDocCategorySizeDatePackage
Popups.javaAPI DocExample4221Mon Aug 27 20:12:26 BST 2007com.google.gwt.sample.kitchensink.client

Popups

public class Popups extends Sink implements com.google.gwt.user.client.ui.ClickListener
Demonstrates {@link com.google.gwt.user.client.ui.PopupPanel} and {@link com.google.gwt.user.client.ui.DialogBox}.

Fields Summary
private com.google.gwt.user.client.ui.Button
dialogButton
private com.google.gwt.user.client.ui.Button
popupButton
Constructors Summary
public Popups()


    
    VerticalPanel panel = new VerticalPanel();
    panel.add(popupButton);
    panel.add(dialogButton);

    ListBox list = new ListBox();
    list.setVisibleItemCount(1);
    for (int i = 0; i < 10; ++i) {
      list.addItem("list item " + i);
    }
    panel.add(list);

    panel.setSpacing(8);
    initWidget(panel);
  
Methods Summary
public static SinkInfoinit()

    return new SinkInfo(
        "Popups",
        "<h2>Popups and Dialog Boxes</h2>"
            + "<p>This page demonstrates GWT's built-in support for in-page "
            + "popups.  The first is a very simple informational popup that closes "
            + "itself automatically when you click off of it.  The second is a more "
            + "complex draggable dialog box. If you're wondering why there's "
            + "a list box at the bottom, it's to demonstrate that you can drag the "
            + "dialog box over it (this obscure corner case often renders incorrectly "
            + "on some browsers).</p>") {

      public Sink createInstance() {
        return new Popups();
      }

      public String getColor() {
        return "#bf2a2a";
      }
    };
  
public voidonClick(com.google.gwt.user.client.ui.Widget sender)

    if (sender == popupButton) {
      MyPopup p = new MyPopup();
      int left = sender.getAbsoluteLeft() + 10;
      int top = sender.getAbsoluteTop() + 10;
      p.setPopupPosition(left, top);
      p.show();
    } else if (sender == dialogButton) {
      DialogBox dlg = new MyDialog();
      dlg.center();
    }
  
public voidonShow()