/**
   * The constants used in this Content Widget.
   */
  public static interface CwConstants extends Constants,
      ContentWidget.CwConstants {
    String cwAbsolutePanelClickMe();

    String cwAbsolutePanelDescription();

    String cwAbsolutePanelHelloWorld();

    String cwAbsolutePanelItemsToMove();

    String cwAbsolutePanelLeft();

    String cwAbsolutePanelName();

    String cwAbsolutePanelTop();

    String[] cwAbsolutePanelWidgetNames();
  }

  /**
   * An instance of the constants.
   */
  private CwConstants constants;

  /**
   * The input field used to set the left position of a {@link Widget}.
   */
  private TextBox leftPosBox = null;

  /**
   * The list box of items that can be repositioned.
   */
  private ListBox listBox = new ListBox();

  /**
   * The input field used to set the top position of a {@link Widget}.
   */
  private TextBox topPosBox = null;

  /**
   * A mapping between the name of a {@link Widget} and the widget in the
   * {@link AbsolutePanel}.
   */
  private Map<String, Widget> widgetMap = null;

  /**
   * Initialize this example.
   */
  @Override
  public Widget onInitialize() {
    // Create a new panel
    widgetMap = new HashMap<String, Widget>();
    absolutePanel = new AbsolutePanel();
    absolutePanel.setSize("250px", "250px");
    absolutePanel.ensureDebugId("cwAbsolutePanel");

    // Add an HTML widget to the panel
    String[] widgetNames = constants.cwAbsolutePanelWidgetNames();
    HTML text = new HTML(constants.cwAbsolutePanelHelloWorld());
    absolutePanel.add(text, 10, 20);
    widgetMap.put(widgetNames[0], text);

    // Add a Button to the panel
    Button button = new Button(constants.cwAbsolutePanelClickMe());
    absolutePanel.add(button, 80, 45);
    widgetMap.put(widgetNames[1], button);

    // Add a Button to the panel
    Grid grid = new Grid(2, 3);
    grid.setBorderWidth(1);
    for (int i = 0; i < 3; i++) {
      grid.setHTML(0, i, i + "");
      grid.setWidget(1, i, Showcase.images.gwtLogoThumb().createImage());
    }
    absolutePanel.add(grid, 60, 100);
    widgetMap.put(widgetNames[2], grid);

    // Wrap the absolute panel in a DecoratorPanel
    DecoratorPanel absolutePanelWrapper = new DecoratorPanel();
    absolutePanelWrapper.setWidget(absolutePanel);

    // Create the options bar
    DecoratorPanel optionsWrapper = new DecoratorPanel();
    optionsWrapper.setWidget(createOptionsBar());

    // Add the components to a panel and return it
    HorizontalPanel mainLayout = new HorizontalPanel();
    mainLayout.setSpacing(10);
    mainLayout.add(optionsWrapper);
    mainLayout.add(absolutePanelWrapper);

    return mainLayout;
  }

  /**
   * Reposition an item when the user changes the value in the top or left
   * position text boxes.
   */
  private void repositionItem() {
    // Use a DeferredCommand to allow the key to take effect in the browser
    DeferredCommand.addCommand(new Command() {
      public void execute() {
        // Get the selected item to move
        String name = listBox.getValue(listBox.getSelectedIndex());
        Widget item = widgetMap.get(name);

        // Reposition the item
        try {
          int top = Integer.parseInt(topPosBox.getText());
          int left = Integer.parseInt(leftPosBox.getText());
          absolutePanel.setWidgetPosition(item, left, top);
        } catch (NumberFormatException e) {
          // Ignore invalid user input
          return;
        }
      }
    });
  }

  /**
   * Update the top and left position text fields when the user selects a new
   * item to move.
   */
  private void updateSelectedItem() {
    String name = listBox.getValue(listBox.getSelectedIndex());
    Widget item = widgetMap.get(name);
    topPosBox.setText((absolutePanel.getWidgetTop(item) - 1) + "");
    leftPosBox.setText((absolutePanel.getWidgetLeft(item) - 1) + "");
  }