1 10 11 package org.netbeans.modules.piagetproject.treestructure; 12 13 import java.io.File ; 14 import java.io.IOException ; 15 import javax.swing.AbstractAction ; 16 import javax.swing.Action ; 17 import org.openide.nodes.AbstractNode; 18 19 23 public class DeleteAction extends AbstractAction { 24 25 AbstractNode node; 26 String filepath; 27 28 29 public DeleteAction(AbstractNode node, String filepath) { 30 this.node = node; 31 this.filepath = filepath; 32 putValue(Action.NAME, "delete"); 33 } 34 35 public void actionPerformed(java.awt.event.ActionEvent e) { 36 File f = new File (filepath); 37 delete(f); 38 try { 39 node.destroy(); 40 } catch (IOException ex) { 41 ex.printStackTrace(System.out); 42 } 43 } 44 45 private void delete(File f) { 46 if(f.isDirectory()) { 47 File content [] = f.listFiles(); 48 for (int i=0; i<content.length; i++) delete(content [i]); 49 } 50 f.delete(); 51 } 52 53 } 54 | Popular Tags |