1 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 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 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 |