1 26 package org.objectweb.openccm.explorer.menu; 27 28 import java.io.File ; 29 import java.awt.Component ; 30 import javax.swing.ImageIcon ; 31 import javax.swing.JFileChooser ; 32 import java.net.URL ; 33 import java.net.URLClassLoader ; 34 35 42 public class LoadJarFileAction 43 extends AbstractMenuAction { 44 45 46 protected JFileChooser fileChooser_; 47 48 49 protected Component parent_; 50 51 54 public LoadJarFileAction(String nom, ImageIcon image, String desc, Integer mnemonic, org.objectweb.fractal.api.Component tree, Component parent) { 55 super(nom, image, desc, mnemonic, tree); 56 fileChooser_ = new JFileChooser (); 57 fileChooser_.setDialogTitle("Loads a new jar file ..."); 58 parent_ = parent; 59 } 60 61 64 public void actionPerformed(java.awt.event.ActionEvent ae) { 65 int returnVal = fileChooser_.showOpenDialog(parent_); 66 if (returnVal == JFileChooser.APPROVE_OPTION) { 67 File file = fileChooser_.getSelectedFile(); 68 try { 69 URL url = file.toURL(); 70 71 URL f[] = new URL [] { url }; 72 URLClassLoader oldCL = (URLClassLoader ) Thread.currentThread().getContextClassLoader(); 73 URLClassLoader newCL = URLClassLoader.newInstance(f, oldCL); 74 Thread.currentThread().setContextClassLoader(newCL); 75 } catch (java.net.MalformedURLException e) { 76 77 } 78 treeItf_.refreshAll(); 79 } 80 } 81 82 } 83 | Popular Tags |