1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package mk.fsgrep.gui;
26
27
28 import java.awt.*;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
31 import java.awt.event.WindowAdapter;
32 import java.awt.event.WindowEvent;
33
34 import javax.swing.*;
35
36 import mk.fsgrep.util.output.TextAreaOutput;
37
38
39 /***
40 *
41 *
42 * @author Murali Krishnan
43 *
44 */
45 public class FilelistDisplay extends JFrame {
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 private JTextArea _textArea = new JTextArea("", 30, 60);
61 private JButton _buttonOk = new JButton("OK");
62
63
64
65
66
67
68 public FilelistDisplay()
69 {
70 super("FileList");
71
72 defineActions();
73 makeFrame();
74 }
75
76
77
78
79
80 protected JTextArea getTextArea() {return _textArea;}
81 protected JButton getButtonOk() {return _buttonOk;}
82
83
84
85
86
87
88
89
90
91
92
93 protected void defineActions() {
94 getTextArea().setEditable(false);
95
96 getButtonOk().addActionListener(new ActionListener() {
97 public void actionPerformed (ActionEvent aEvent) {
98 setVisible(false);
99 }
100 });
101
102 addWindowListener(new WindowAdapter() {
103 public void windowActivated(WindowEvent e) {
104 getButtonOk().grabFocus();
105 }
106 });
107 }
108
109
110 protected void makeFrame() {
111 getContentPane().setLayout(new BorderLayout());
112
113 JScrollPane scrollPane = new JScrollPane();
114 scrollPane.setViewportView(getTextArea());
115
116 JPanel buttonPanel = new JPanel();
117 {
118 buttonPanel.setLayout(new BorderLayout());
119 buttonPanel.add(getButtonOk(), BorderLayout.EAST);
120 }
121
122 getContentPane().add(scrollPane, BorderLayout.CENTER);
123 getContentPane().add(buttonPanel, BorderLayout.SOUTH);
124
125 pack();
126 }
127
128
129
130
131
132 public TextAreaOutput getOutput() {
133 TextAreaOutput result = new TextAreaOutput(getTextArea());
134
135 return result;
136 }
137
138
139 public void clearText() {
140 getTextArea().setText("");
141 }
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158 }