import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; 1 2 void jButton1_actionPerformed(ActionEvent e) { 3 // File (or directory) with old name 4 File file = new File("c:\\test1.txt"); 5 6 // File (or directory) with new name 7 File file2 = new File("c:\\test2.txt"); 8 9 // Rename file (or directory) 10 boolean success = file.renameTo(file2); 11 if (success == true) { 12 this.setTitle("File rename was a success!"); 13 } 14 else { 15 this.setTitle("Failure"); 16 } 17 18 } 19