KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jftp > gui > base > Properties


1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * 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.base;
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
29 public class Properties extends HFrame implements ActionListener
30 {
31     private Label fileL = new Label("File: ");
32     private Label sizeL = new Label("Size: ? bytes ");
33     private HButton ok = new HButton("Dismiss");
34     private HPanel okP = new HPanel();
35     private String JavaDoc type = "";
36     private String JavaDoc file = "";
37
38     public Properties(String JavaDoc file, String JavaDoc type)
39     {
40         this.file = file;
41         this.type = type;
42
43         setSize(300, 110);
44         setTitle("File properties...");
45         setLocation(150, 150);
46         setLayout(new GridLayout(3, 1));
47
48         okP.add(ok);
49         add(sizeL);
50         add(fileL);
51         add(okP);
52         ok.addActionListener(this);
53
54         process();
55         setVisible(true);
56     }
57
58     private void process()
59     {
60         if(type.equals("local"))
61         {
62             File f = new File(JFtp.localDir.getPath() + file);
63             sizeL.setText("Size: " + Long.toString(f.length()) + " bytes");
64
65             try
66             {
67                 fileL.setText("File: " + f.getCanonicalPath());
68             }
69             catch(Exception JavaDoc ex)
70             {
71                 Log.debug(ex.toString());
72             }
73
74             sizeL.setText("Size: " + Long.toString(f.length()) + " bytes");
75         }
76
77         if(type.equals("remote"))
78         {
79             fileL.setText("File: " + JFtp.remoteDir.getPath() + file);
80         }
81     }
82
83     public void actionPerformed(ActionEvent e)
84     {
85         if(e.getSource() == ok)
86         {
87             setVisible(false);
88         }
89     }
90 }
91
Popular Tags