import java.applet.Applet; import java.awt.*; public class DialogBug extends Applet { private Button _mainButton; private TextField _labelTextField; private DialogBugDialog _dialog; public void init() { setLayout(new BorderLayout()); _mainButton = new Button("Click Here For Dialog Window"); add("Center",_mainButton); _labelTextField = new TextField("Dialog Message Should Appear Here"); add("South", _labelTextField); } public boolean handleEvent (Event event) { if (event.target == _mainButton && event.id == Event.ACTION_EVENT) { _dialog = new DialogBugDialog(getFrame(), true); _dialog.show(); System.out.println(_dialog.getResult()); _labelTextField.setText(_dialog.getResult()); return true; } return super.handleEvent(event); } private Frame getFrame() { Container c = getParent(); while (c != null && !(c instanceof Frame)) { c = c.getParent(); } return (Frame)c; } }