01: /*
02: * This program is free software; you can redistribute it and/or
03: * modify it under the terms of the GNU General Public License
04: * as published by the Free Software Foundation; either version 2
05: * of the License, or (at your option) any later version.
06: *
07: * This program is distributed in the hope that it will be useful,
08: * but WITHOUT ANY WARRANTY; without even the implied warranty of
09: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10: * GNU General Public License for more details.
11:
12: * You should have received a copy of the GNU General Public License
13: * along with this program; if not, write to the Free Software
14: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15: */
16: package net.sf.jftp.gui.tasks;
17:
18: import net.sf.jftp.*;
19: import net.sf.jftp.gui.framework.*;
20: import net.sf.jftp.system.logging.Log;
21: import net.sf.jftp.util.*;
22:
23: import java.awt.*;
24: import java.awt.event.*;
25:
26: import java.io.*;
27:
28: import javax.swing.*;
29:
30: public class ExternalDisplayer extends HFrame implements ActionListener {
31: private JTextArea info = new JTextArea(25, 50);
32: private JButton close = new JButton("Close");
33:
34: public ExternalDisplayer(java.net.URL file) {
35: setTitle("Info...");
36: setLocation(50, 50);
37: setSize(600, 540);
38: getContentPane().setLayout(new BorderLayout());
39:
40: addWindowListener(new WindowAdapter() {
41: public void windowClosing(WindowEvent e) {
42: dispose();
43: }
44: });
45: load(file);
46: info.setEditable(false);
47:
48: JScrollPane jsp = new JScrollPane(info);
49: getContentPane().add("Center", jsp);
50:
51: HPanel closeP = new HPanel();
52: closeP.setLayout(new FlowLayout(FlowLayout.CENTER));
53: closeP.add(close);
54:
55: close.addActionListener(this );
56:
57: getContentPane().add("South", closeP);
58:
59: info.setCaretPosition(0);
60: setVisible(true);
61: pack();
62: }
63:
64: public void actionPerformed(ActionEvent e) {
65: if (e.getSource() == close) {
66: this .dispose();
67: }
68: }
69:
70: private void load(java.net.URL file) {
71: String data = "";
72: String now = "";
73:
74: try {
75: DataInput in = new DataInputStream(new BufferedInputStream(
76: file.openStream()));
77:
78: while ((data = in.readLine()) != null) {
79: now = now + data + "\n";
80: }
81: } catch (IOException e) {
82: Log.debug(e + " @Displayer.load()");
83: }
84:
85: info.setText(now);
86: }
87:
88: public Insets getInsets() {
89: Insets std = super .getInsets();
90:
91: return new Insets(std.top + 5, std.left + 5, std.bottom + 5,
92: std.right + 5);
93: }
94: }
|