import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class UseMessageBox {
static Frame myWindow = new Frame("Using MessageBox");
public static void main(String args[]){
myWindow.setLayout(new FlowLayout());
Button testButton=new Button("Press Me");
testButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
MessageBox msgBox=new
MessageBox(myWindow,"Message come from Java","Coffee");
msgBox.show();
}
});
myWindow.add(testButton);
//Handle Window close message
myWindow.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent event){
System.exit(0);
}
});
// Have to give the frame a size before it is visible
myWindow.setSize(new Dimension(300, 100));
// Make the frame appear on the screen
myWindow.show();
}
}