1   package debugger.gui.debugging.debugviews;
2   
3   import javax.swing.*;
4   import java.awt.*;
5   import java.awt.event.FocusAdapter;
6   import java.awt.event.FocusEvent;
7   import java.awt.event.MouseAdapter;
8   import java.awt.event.MouseEvent;
9   import java.util.Iterator;
10  
11  /**
12   * Copyright (c) Ontos AG (http://www.ontosearch.com).
13   * This class is part of JAPE Debugger component for
14   * GATE (Copyright (c) "The University of Sheffield" see http://gate.ac.uk/) <br>
15   * @author Andrey Shafirin, Oleg Mishenko
16   */
17  
18  class InfoWindow extends JWindow {
19      private PrimaryTextPanel panel;
20  
21      public InfoWindow(PrimaryTextPanel panel, JFrame owner) {
22          super(owner);
23          this.panel = panel;
24          initialize();
25      }
26  
27      public void initialize() {
28          this.getContentPane().setLayout(new BorderLayout());
29          JTextPane textPane = new JTextPane();
30          textPane.setBackground(new Color(255, 255, 170));
31          String text = "";
32          for (Iterator it = panel.getAnnotations().iterator(); it.hasNext();) {
33              text = text + it.next() + "\n";
34          }
35          textPane.setText(text);
36          textPane.setEditable(false);
37          textPane.setBorder(BorderFactory.createEtchedBorder());
38          this.getContentPane().add(new JScrollPane(textPane));
39          textPane.setRequestFocusEnabled(true);
40          textPane.requestFocus();
41          textPane.addMouseListener(new MouseAdapter() {
42              public void mouseClicked(MouseEvent e) {
43                  InfoWindow.this.setVisible(false);
44              }
45          });
46          textPane.addFocusListener(new FocusAdapter() {
47              public void focusLost(FocusEvent e) {
48                  InfoWindow.this.setVisible(false);
49              }
50          });
51          this.setSize(400, 200);
52      }
53  }