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

Widgets

public class Widgets extends Sink implements com.google.gwt.user.client.Command
Demonstrates the various button widgets.

Fields Summary
private com.google.gwt.user.client.ui.Button
disabledButton
private com.google.gwt.user.client.ui.CheckBox
disabledCheck
private com.google.gwt.user.client.ui.Button
normalButton
private com.google.gwt.user.client.ui.CheckBox
normalCheck
private com.google.gwt.user.client.ui.VerticalPanel
panel
private com.google.gwt.user.client.ui.RadioButton
radio0
private com.google.gwt.user.client.ui.RadioButton
radio1
private com.google.gwt.user.client.ui.RadioButton
radio2
private com.google.gwt.user.client.ui.RadioButton
radio3
private com.google.gwt.user.client.ui.PushButton
pushButton
private com.google.gwt.user.client.ui.ToggleButton
toggleButton
Constructors Summary
public Widgets(Sink.Images images)


     
    pushButton = new PushButton(images.gwtLogo().createImage());
    toggleButton = new ToggleButton(images.gwtLogo().createImage());

    HorizontalPanel hp;

    panel.add(createMenu());

    panel.add(hp = new HorizontalPanel());
    hp.setSpacing(8);
    hp.add(normalButton);
    hp.add(disabledButton);

    panel.add(hp = new HorizontalPanel());
    hp.setSpacing(8);
    hp.add(normalCheck);
    hp.add(disabledCheck);

    panel.add(hp = new HorizontalPanel());
    hp.setSpacing(8);
    hp.add(radio0);
    hp.add(radio1);
    hp.add(radio2);
    hp.add(radio3);

    panel.add(hp = new HorizontalPanel());
    hp.setSpacing(8);
    hp.add(pushButton);
    hp.add(toggleButton);

    disabledButton.setEnabled(false);
    disabledCheck.setEnabled(false);
    radio2.setEnabled(false);

    panel.setSpacing(8);
    initWidget(panel);
  
Methods Summary
public com.google.gwt.user.client.ui.MenuBarcreateMenu()

    MenuBar menu = new MenuBar();
    menu.setAutoOpen(true);

    MenuBar subMenu = new MenuBar(true);
    subMenu.addItem("<code>Code</code>", true, this);
    subMenu.addItem("<strike>Strikethrough</strike>", true, this);
    subMenu.addItem("<u>Underlined</u>", true, this);

    MenuBar menu0 = new MenuBar(true);
    menu0.addItem("<b>Bold</b>", true, this);
    menu0.addItem("<i>Italicized</i>", true, this);
    menu0.addItem("More »", true, subMenu);
    MenuBar menu1 = new MenuBar(true);
    menu1.addItem("<font color='#FF0000'><b>Apple</b></font>", true, this);
    menu1.addItem("<font color='#FFFF00'><b>Banana</b></font>", true, this);
    menu1.addItem("<font color='#FFFFFF'><b>Coconut</b></font>", true, this);
    menu1.addItem("<font color='#8B4513'><b>Donut</b></font>", true, this);
    MenuBar menu2 = new MenuBar(true);
    menu2.addItem("Bling", this);
    menu2.addItem("Ginormous", this);
    menu2.addItem("<code>w00t!</code>", true, this);

    menu.addItem(new MenuItem("Style", menu0));
    menu.addItem(new MenuItem("Fruit", menu1));
    menu.addItem(new MenuItem("Term", menu2));

    menu.setWidth("100%");

    return menu;
  
public voidexecute()

    Window.alert("Thank you for selecting a menu item.");
  
public static SinkInfoinit(Sink.Images images)

    return new SinkInfo("Widgets", "<h2>Basic Widgets</h2>" +
      "<p>GWT has all sorts of the basic widgets you would expect from any " +
      "toolkit.</p><p>Below, you can see various kinds of buttons, check boxes, " +
      "radio buttons, and menus.</p>") {

      public Sink createInstance() {
        return new Widgets(images);
      }

      public String getColor() {
        return "#bf2a2a";
      }
    };
  
public voidonShow()