KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jftp > gui > base > dir > DirCanvas


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.dir;
17
18 import net.sf.jftp.config.Settings;
19 import net.sf.jftp.gui.base.UITool;
20 import net.sf.jftp.gui.framework.*;
21 import net.sf.jftp.gui.tasks.PathChanger;
22
23 import java.awt.*;
24 import java.awt.event.*;
25
26 import javax.swing.*;
27 import javax.swing.event.*;
28
29
30 public class DirCanvas extends JPanel implements MouseListener
31 {
32     JLabel text = new JLabel(" ");
33     private Dir target;
34
35     public DirCanvas(Dir target)
36     {
37         this.target = target;
38         setLayout(new FlowLayout(FlowLayout.LEFT));
39         add(text);
40         addMouseListener(this);
41         setVisible(true);
42     }
43
44     public void mouseClicked(MouseEvent e)
45     {
46         if(target.getType().equals("local"))
47         {
48             String JavaDoc tmp = UITool.getPathFromDialog(Settings.defaultWorkDir);
49
50             if(tmp != null)
51             {
52                 target.setPath(tmp);
53                 target.fresh();
54             }
55         }
56         else
57         {
58             PathChanger p = new PathChanger("remote");
59             target.fresh();
60         }
61     }
62
63     public void mousePressed(MouseEvent e)
64     {
65     }
66
67     public void mouseReleased(MouseEvent e)
68     {
69     }
70
71     public void mouseEntered(MouseEvent e)
72     {
73     }
74
75     public void mouseExited(MouseEvent e)
76     {
77     }
78
79     public void setText(String JavaDoc msg)
80     {
81         text.setText(msg);
82         validate();
83     }
84
85     public void paintComponent(Graphics g)
86     {
87         g.setColor(GUIDefaults.light);
88         g.fillRect(0, 0, getSize().width, getSize().height);
89         g.setColor(GUIDefaults.front);
90         g.drawRect(0, 0, getSize().width - 1, getSize().height - 1);
91         g.drawRect(0, 0, getSize().width - 2, getSize().height - 2);
92     }
93 }
94
Popular Tags