1   package main;
2   
3   import intellego.Intellego;
4   import util.*;
5   import interfaces.*;
6   import real.*;
7   
8   import java.awt.*;
9   import java.awt.event.*;
10  import javax.swing.*;
11  
12  /**
13  * Providea a general purpose dialog box to display messages from the
14  * system to the user.
15  *
16  * @author Graham Ritchie
17  */
18  class IntellegoDialog extends JDialog implements ActionListener
19  {
20      JLabel message;
21      JButton OK;
22      static int openFrameCount=5;
23      static final int xOffset = 30, yOffset = 30;
24      
25      /**
26      * Creates and displays the dialog box
27      *
28      * @param text the message to be displyed to the user
29      */
30      public IntellegoDialog(String text)
31      {
32          openFrameCount++;
33          
34          setTitle("Intellego:");
35          setSize(400,100);
36          setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
37          
38          Container c=getContentPane();
39          c.setLayout(new BorderLayout(1,1));
40  
41          Container top=new Container();
42          top.setLayout(new FlowLayout());
43  
44          Container bottom=new Container();
45          bottom.setLayout(new FlowLayout());
46  
47          (OK=new JButton("OK")).addActionListener(this);
48          message=new JLabel(text);
49  
50          top.add("Center",message);
51          bottom.add("Center",OK);
52  
53          c.add("North",top);
54          c.add("South",bottom);
55          
56          show();
57      }
58      
59      /**
60      * Disposes with the dialog box when the user clicks on OK
61      *
62      * @param e the action event
63      */
64      public void actionPerformed(ActionEvent e)
65      {
66          dispose();
67          openFrameCount--;
68      }
69  }
70