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.net.*; 21 import net.sf.jftp.system.logging.Log; 22 import net.sf.jftp.util.*; 23 24 import java.awt.*; 25 import java.awt.event.*; 26 27 import java.io.*; 28 29 30 public class Renamer extends HFrame implements ActionListener 31 { 32 public HTextField text; 33 private HButton ok = new HButton("Ok"); 34 private HPanel okP = new HPanel(); 35 private String oldName; 36 private String path; 37 38 public Renamer(String oldName, String path) 39 { 40 this.oldName = oldName; 41 this.path = path; 42 43 setSize(400, 80); 44 setTitle("Enter new name..."); 45 setLocation(150, 150); 46 getContentPane().setLayout(new FlowLayout()); 47 48 text = new HTextField("Name: ", oldName); 49 getContentPane().add(text); 50 getContentPane().add(ok); 51 ok.addActionListener(this); 52 text.text.addActionListener(this); 53 54 setVisible(true); 55 } 56 57 public void actionPerformed(ActionEvent e) 58 { 59 if((e.getSource() == ok) || (e.getSource() == text.text)) 60 { 61 String name = text.getText(); 62 setVisible(false); 63 64 File f = new File(path + oldName); 65 66 if(f.exists()) 67 { 68 f.renameTo(new File(path + name)); 69 } 70 71 JFtp.localUpdate(); 72 73 Log.debug("Successfully renamed."); 74 } 75 } 76 } 77 | Popular Tags |