public static void main(String[] _args) { BuFileChooser p=new BuFileChooser(System.getProperty("user.dir")); p.setDragEnabled(true); p.setControlButtonsAreShown(false); if(p.getBorder() instanceof EmptyBorder) p.setBorder(BuLib.getEmptyBorder(5)); JFrame f=new JFrame("File Chooser"); f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); f.getContentPane().add(p); f.pack(); f.show(); } }
/** * Verifie que le chemin saisi contient bien un jar sinon demande correction a l'utilisateur. * @param pathPresumePourJar * @return */ public String verifPathForJarIsCorrect(String pathPresumePourJar){ File test=new File(pathPresumePourJar); if(test==null || !test.exists() || test.isDirectory()){ ui_.error(FudaaResource.FUDAA.getString("Erreur, Il n'y a pas de fichier jar de document l'adresse suivante: "+pathPresumePourJar)); BuFileChooser chooser=new BuFileChooser(); int rep=chooser.showOpenDialog(ui_.getParentComponent()); if(rep==BuFileChooser.APPROVE_OPTION){ pathPresumePourJar=chooser.getSelectedFile().getAbsolutePath(); } } return pathPresumePourJar; }
/** * Display a file chooser dialog box. * * @param owner <code>Component</code> which 'owns' the dialog * @param mode Can be either <code>LOAD</code> or <code>SAVE</code> * @return The path to selected file, null otherwise */ public static String chooseFile(Component owner, int mode) { BuFileChooser chooser = new BuFileChooser(); if (mode == OPEN) chooser.setDialogType(JFileChooser.OPEN_DIALOG); else if (mode == SAVE) chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileHidingEnabled(true); if (chooser.showDialog(owner, null) == JFileChooser.APPROVE_OPTION) return chooser.getSelectedFile() .getAbsolutePath(); return null; }
/** * Display a file chooser dialog box. * @param owner <code>Component</code> which 'owns' the dialog * @param mode Can be either <code>LOAD</code> or <code>SAVE</code> * @return The path to selected file, null otherwise */ public static String chooseFile(Component owner, int mode) { BuFileChooser chooser = new BuFileChooser(); if (mode == OPEN) chooser.setDialogType(JFileChooser.OPEN_DIALOG); else if (mode == SAVE) chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileHidingEnabled(true); if (chooser.showDialog(owner, null) == JFileChooser.APPROVE_OPTION) return chooser.getSelectedFile().getAbsolutePath(); return null; }
/** * Methode qui sauvegarde le fichier en cours de lecture sur l'emplacement voulu. */ public void sauvegarderFichierPdf(){ JarEntry fichierJar=getCurrentJarEntry(); if(fichierJar==null) return; File fichierDest=null; BuFileChooser chooser=new BuFileChooser(); int rep=chooser.showOpenDialog(ui_.getParentComponent()); if(rep==BuFileChooser.APPROVE_OPTION){ fichierDest=chooser.getSelectedFile(); } if(fichierDest!=null){ generateFileFromJar(fichierJar, fichierDest); } }
private String getDirectory(String _default) { String r=FuLib.expandedPath(_default); // System.err.println("### FD begin"); BuFileChooser chooser=new BuFileChooser(); chooser.setDialogTitle(getS("Repertoire")); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setFileHidingEnabled(true); chooser.setMultiSelectionEnabled(false); chooser.resetChoosableFileFilters(); File f=new File(r); if(f.exists()) chooser.setCurrentDirectory(f); int returnVal=chooser.showDialog(this,getS("Slectionner")); // System.err.println("### FD end"); if(returnVal == JFileChooser.APPROVE_OPTION) { f=chooser.getSelectedFile(); // System.err.println("### f="+f); if(f!=null) r=f.getPath(); } return FuLib.reducedPath(r); } }
private String getDirectory(String _default) { String r=FuLib.expandedPath(_default); // System.err.println("### FD begin"); BuFileChooser chooser=new BuFileChooser(); chooser.setDialogTitle(getS("Repertoire")); chooser.setFileSelectionMode(BuFileChooser.DIRECTORIES_ONLY); chooser.setFileHidingEnabled(true); chooser.setMultiSelectionEnabled(false); chooser.resetChoosableFileFilters(); File f=new File(r); if(f.exists()) chooser.setCurrentDirectory(f); int returnVal=chooser.showDialog(this,getS("Slectionner")); // System.err.println("### FD end"); if(returnVal == BuFileChooser.APPROVE_OPTION) { f=chooser.getSelectedFile(); // System.err.println("### f="+f); if(f!=null) r=f.getPath(); } return FuLib.reducedPath(r); } }
BuFileChooser chooser = new BuFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileHidingEnabled(true);
BuFileChooser chooser = new BuFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileHidingEnabled(true);