The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

here you go

Posted by richard on February 04, 2001 at 6:20 PM

try this:


import java.awt.*;
import java.awt.event.*;
/**
* Creates a PopUp Modal dialog box
* Creation date: (26-Nov-00 14:38:07)
* @author: RJo
*/
public class OkPopUp extends Dialog implements ActionListener
{
Button ok = new Button("OK");
Label messageLabel;
/**
* DeleteConfirmPopUp constructor comment.
*/
public OkPopUp(Frame hostFrame, String title, boolean mode, String message)
{
super(hostFrame,"PopUp Message Window", mode);

setLayout(new FlowLayout());
setTitle(title);
messageLabel = new Label( message );

add( messageLabel );
add( ok );
ok.addActionListener(this);

setBounds(50,50,300, 100);
}
public void actionPerformed(ActionEvent e)
{
setVisible(false);
}
}

In your applet declare these objects:

private OkPopUp popUp;
private Frame popUpFrame = new Frame();

add this method:

/**
* This method pops up a message with an OK button
* @param message java.lang.String
*/
public void doPopUp(String message)
{
popUp = new OkPopUp(popUpFrame, "Information", true, message);
popUp.show();
}

and use like so:


doPopUp("this is an information message");

This works in jdk 1.1.6

richard




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us