package com.lamatek.swingextras;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import com.lamatek.event.ActionAdapter;
/**
* Provides a simple 'Splash Screen' to display during application
* loading or for a 'Help | about' menu option.
*/
public class IntroDialog extends JDialog {
private JButton okay;
/**
* Constructs and displays a splash screen with the supplied
* image, title and parent. Once the parent is visible, the
* splash screen disposes.
*
* @param owner Parent frame
* @param text Splash screen title text
* @param image The image to display
*/
public IntroDialog(JFrame owner, String text, Image image) {
super(owner, text);
ImagePanel panel = new ImagePanel(image);
getContentPane().add("Center", panel);
JPanel bp = new JPanel(new FlowLayout());
okay = (JButton) bp.add(new JButton("Okay"));
okay.addActionListener(new ActionAdapter() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
getContentPane().add("South", bp);
pack();
Dimension screen = getToolkit().getScreenSize();
setLocation((screen.getSize().width - getSize().width) / 2, (screen.getSize().height - getSize().height) / 2);
show();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
}
});
}
}