1 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 31 public class ExternalDisplayer extends HFrame implements ActionListener 32 { 33 private JTextArea info = new JTextArea(25, 50); 34 private JButton close = new JButton("Close"); 35 36 public ExternalDisplayer(java.net.URL file) 37 { 38 setTitle("Info..."); 39 setLocation(50, 50); 40 setSize(600, 540); 41 getContentPane().setLayout(new BorderLayout()); 42 43 addWindowListener(new WindowAdapter() 44 { 45 public void windowClosing(WindowEvent e) 46 { 47 dispose(); 48 } 49 }); 50 load(file); 51 info.setEditable(false); 52 53 JScrollPane jsp = new JScrollPane(info); 54 getContentPane().add("Center", jsp); 55 56 HPanel closeP = new HPanel(); 57 closeP.setLayout(new FlowLayout(FlowLayout.CENTER)); 58 closeP.add(close); 59 60 close.addActionListener(this); 61 62 getContentPane().add("South", closeP); 63 64 info.setCaretPosition(0); 65 setVisible(true); 66 pack(); 67 } 68 69 public void actionPerformed(ActionEvent e) 70 { 71 if(e.getSource() == close) 72 { 73 this.dispose(); 74 } 75 } 76 77 private void load(java.net.URL file) 78 { 79 String data = ""; 80 String now = ""; 81 82 try 83 { 84 DataInput in = new DataInputStream(new BufferedInputStream(file.openStream())); 85 86 while((data = in.readLine()) != null) 87 { 88 now = now + data + "\n"; 89 } 90 } 91 catch(IOException e) 92 { 93 Log.debug(e + " @Displayer.load()"); 94 } 95 96 info.setText(now); 97 } 98 99 public Insets getInsets() 100 { 101 Insets std = super.getInsets(); 102 103 return new Insets(std.top + 5, std.left + 5, std.bottom + 5, 104 std.right + 5); 105 } 106 } 107 | Popular Tags |