1 package autotest.common.ui; 2 3 import com.google.gwt.event.dom.client.ClickEvent; 4 import com.google.gwt.event.dom.client.ClickHandler; 5 import com.google.gwt.user.client.ui.Button; 6 import com.google.gwt.user.client.ui.DialogBox; 7 import com.google.gwt.user.client.ui.FlexTable; 8 import com.google.gwt.user.client.ui.Widget; 9 10 /** 11 * Simple DialogBox subclass that displays a title, contents, and an OK button to close the dialog. 12 * 13 */ 14 public class SimpleDialog extends DialogBox { 15 public SimpleDialog(String title, Widget contents) { 16 super(false, false); 17 18 FlexTable flex = new FlexTable(); 19 flex.setText(0, 0, title); 20 flex.getFlexCellFormatter().setStylePrimaryName(0, 0, "field-name"); 21 22 flex.setWidget(1, 0, contents); 23 24 Button ok = new Button("OK"); 25 ok.addClickHandler(new ClickHandler() { 26 public void onClick(ClickEvent event) { 27 hide(); 28 } 29 }); 30 flex.setWidget(2, 0, ok); 31 32 add(flex); 33 } 34 } 35