1 package net.sourceforge.jnipp.gui;
2
3 import javax.swing.JButton;
4 import javax.swing.JLabel;
5 import javax.swing.JDialog;
6 import javax.swing.JFrame;
7 import java.awt.BorderLayout;
8 import java.awt.event;
9
10 public class MessageBox extends JDialog implements ActionListener
11 {
12
13 JButton cmdOk;
14
15 //TODO: Make this thing ALOT less ugly.
16
17 public MessageBox(JFrame parentframe,String title,String label)
18 {
19 super(parentframe,title,true);
20
21 JLabel lbl = new JLabel(label);
22
23 cmdOk = new JButton("Ok");
24 cmdOk.addActionListener(this);
25
26 getContentPane().add(lbl, BorderLayout.NORTH);
27 getContentPane().add(cmdOk, BorderLayout.SOUTH);
28
29 initWindowListener();
30 pack();
31 }
32
33 public void actionPerformed(ActionEvent e)
34 {
35 hide();
36 }
37
38 private void initWindowListener()
39 {
40 this.addWindowListener( new WindowAdapter()
41 {
42 public void windowClosing(WindowEvent e)
43 {
44 hide();
45 }
46 });
47 }
48 }
49