Good people I managed to get where I wanted, or better already gave to begin...
The code was as shown below, what I am doing is captaining all kinds of selection and what I did with the button open up was to change the text on it no more, but when I got the address of the selected directories I call the method again.
The code:
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
/**
*
* @author Cizo
*/
public class MyFileChooser extends JFrame {
public void seleciona() {
File diretorio = new File("C:\\");
JFileChooser fileChooser = new JFileChooser(diretorio);
fileChooser.resetChoosableFileFilters();
UIManager.put("FileChooser.openDialogTitleText", "Seleçao de aquivos");
UIManager.put("FileChooser.lookInLabelText", "Local");
UIManager.put("FileChooser.openButtonText", "Inserir");
UIManager.put("FileChooser.cancelButtonText", "Sair");
UIManager.put("FileChooser.fileNameLabelText", "Nome do Arquivo");
UIManager.put("FileChooser.filesOfTypeLabelText", "Tipo de Arquivo");
UIManager.put("FileChooser.openButtonToolTipText", "Abrir Selecionado");
UIManager.put("FileChooser.cancelButtonToolTipText", "Sair");
UIManager.put("FileChooser.fileNameHeaderText", "Nome do Arquivo");
UIManager.put("FileChooser.upFolderToolTipText", "Subir Nivel Acima");
UIManager.put("FileChooser.homeFolderToolTipText", "Desktop");
UIManager.put("FileChooser.newFolderToolTipText", "Nova Pasta");
UIManager.put("FileChooser.listViewButtonToolTipText", "Lista");
UIManager.put("FileChooser.newFolderButtonText", "Criar Nova Pasta");
UIManager.put("FileChooser.renameFileButtonText", "Renomear");
UIManager.put("FileChooser.deleteFileButtonText", "Apagar");
UIManager.put("FileChooser.filterLabelText", "Tipo de Arquivos");
UIManager.put("FileChooser.detailsViewButtonToolTipText", "Detalhes");
UIManager.put("FileChooser.fileSizeHeaderText", "Tamanho");
UIManager.put("FileChooser.fileDateHeaderText", "Data de Modificação");
SwingUtilities.updateComponentTreeUI(fileChooser);
fileChooser.setMultiSelectionEnabled(true);
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
File[] dir = null;
switch (fileChooser.showOpenDialog(this)) {
case JFileChooser.APPROVE_OPTION:
dir = fileChooser.getSelectedFiles();
for (File dir1 : dir) {
System.out.println("AQUI > " + dir1);
}
seleciona();
break;
case JFileChooser.CANCEL_OPTION:
JOptionPane.showMessageDialog(null, "Final");
break;
}
}
}
The Jfilechooser looked like this:
I don’t know if it’s gonna work the way you want it to, but you’ve tried it
setMultiSelectionEnabled(true)
? This will allow the selection of more than one file (I just don’t know if it is possible to select them in different folders). Customizing button text is easy, there is thesetApproveButtonText
and think which should have similar option to cancel button. If this is not enough, I suggest in your own code a loop that selects a path, opens the dialog again, etc, until the user chooses everything.– mgibsonbr