//PromptNM.java //A non-modal prompt //andy Harris, 05/00 import java.awt.*; import java.awt.event.*; public class PromptNM extends Frame{ Label lblMessage = new Label(); Button btnOK = new Button("OK"); EventHandler evt = new EventHandler(this); public PromptNM (){ super("Message Box"); setLayout(new GridLayout(0,1)); add(lblMessage); lblMessage.setAlignment(Label.CENTER); Panel pnlButton = new Panel(); add(pnlButton); pnlButton.setLayout(new FlowLayout()); pnlButton.add(btnOK); btnOK.addActionListener(evt); this.addWindowListener(evt); } //end constructor public void say(String message){ lblMessage.setText(message); this.setLocation(100,100); this.setSize(200,200); this.setVisible(true); //this.pack(); } // end say private class EventHandler extends WindowAdapter implements ActionListener{ Frame theFrame; public EventHandler(Frame f){ theFrame = f; } // end constructor public void actionPerformed(ActionEvent e){ // user clicked on OK button theFrame.setVisible(false); } // end actionPerformed public void windowClosing(WindowEvent e){ theFrame.setVisible(false); } // end windowClosing } // end EventHandler def } // end prompt class def