// Example of a pop-up window
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Foo implements ActionListener
{
JButton dismiss = new JButton("Dismiss");
JDialog popup;
public Foo()
{
JFrame window = new JFrame("Main window");
// First argument sets the "owner" of this
// dialog box. Second argument sets modal
// property to "true" (it blocks the rest of
// the program until it's closed).
popup = new JDialog(window, true);
dismiss.addActionListener(this);
popup.add(dismiss);
popup.pack(); // resize to fit components
window.setVisible(true);
popup.setVisible(true);
}
public void actionPerformed (ActionEvent e)
{
// Find out who was clicked
JButton temp = (JButton)e.getSource();
if (temp.equals(dismiss))
{
popup.setVisible(false);
}
}
}