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.lang.*;
10  import java.awt.event.*;
11  import javax.swing.*;
12  import java.io.*;
13  import java.net.*;
14  
15  /**
16  * Provide a window which displays messages from external processes to the user, 
17  * within the main interface.
18  *
19  * @author Graham Ritchie
20  */
21  public class ExternalMessager extends JInternalFrame
22  {
23      private JEditorPane messagePane;
24      static final int xOffset = 30, yOffset = 30;
25      static int openFrameCount = 0;
26      
27      /**
28      * Sets up the message display window
29      */
30      public ExternalMessager()
31      {
32          super("External process messages: ",true,true,true,true);
33          
34          openFrameCount++;
35          
36          // create and add the editor pane
37          messagePane=new JEditorPane();
38          messagePane.setVisible(true);
39          messagePane.setEditable(false);
40          
41          // put it in a scroll pane
42          JScrollPane messageScrollPane = new JScrollPane(messagePane);
43          messageScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
44          messageScrollPane.setPreferredSize(new Dimension(400,600));
45          messageScrollPane.setMinimumSize(new Dimension(10, 10));
46          
47          // and add this to a main content pane
48          JPanel contentPane = new JPanel();
49          BoxLayout box = new BoxLayout(contentPane, BoxLayout.X_AXIS);
50          contentPane.setLayout(box);
51          contentPane.add(messageScrollPane);
52          setContentPane(contentPane);
53          
54          // set the window size
55          setSize(500,300);
56  
57          // and set the window's location.
58          setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
59      }
60      
61      /**
62      * Appends a message to the message pane of the main window
63      *
64      * @param text the test to be appended
65      */
66      public void append(String text)
67      {
68          messagePane.setText(messagePane.getText()+text);
69      } 
70  }
71