@@ -0,0 +1,2087 @@
+// Copyright 2008 Google Inc.%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A// http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage com.google.gwtexpui.user.client;%0A%0Aimport com.google.gwt.user.client.Window;%0Aimport com.google.gwt.user.client.WindowResizeListener;%0Aimport com.google.gwt.user.client.ui.DialogBox;%0A%0A/** A DialogBox that automatically re-centers itself if the window changes */%0Apublic class AutoCenterDialogBox extends DialogBox %7B%0A  private WindowResizeListener recenter;%0A%0A  public AutoCenterDialogBox() %7B%0A  %7D%0A%0A  public AutoCenterDialogBox(final boolean autoHide) %7B%0A    super(autoHide);%0A  %7D%0A%0A  public AutoCenterDialogBox(final boolean autoHide, final boolean modal) %7B%0A    super(autoHide, modal);%0A  %7D%0A%0A  @Override%0A  public void show() %7B%0A    if (recenter == null) %7B%0A      recenter = new WindowResizeListener() %7B%0A        public void onWindowResized(final int width, final int height) %7B%0A          onResize(width, height);%0A        %7D%0A      %7D;%0A      Window.addWindowResizeListener(recenter);%0A    %7D%0A    super.show();%0A  %7D%0A%0A  @Override%0A  protected void onUnload() %7B%0A    if (recenter != null) %7B%0A      Window.removeWindowResizeListener(recenter);%0A      recenter = null;%0A    %7D%0A    super.onUnload();%0A  %7D%0A%0A  /**%0A   * Invoked when the outer browser window resizes.%0A   * %3Cp%3E%0A   * Subclasses may override (but should ensure they still call super.onResize)%0A   * to implement custom logic when a window resize occurs.%0A   * %0A   * @param width new browser window width%0A   * @param height new browser window height%0A   */%0A  protected void onResize(final int width, final int height) %7B%0A    if (isAttached()) %7B%0A      center();%0A    %7D%0A  %7D%0A%7D%0A

Add a simple dialog box that automatically centers itself