RE:Buscador de rutas de directorios
Hola! Mira te pongo cómo lo hago yo:
openItem.addActionListener(
// clase anonima para manejar ActionEvent
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser jFileChooser = new JFileChooser(ruta);
jFileChooser.setAcceptAllFileFilterUsed(false);
jFileChooser.addChoosableFileFilter(new FiltroXML()); jFileChooser.showDialog(vprincipal, "Select file"); file = new String();
File ff = jFileChooser.getSelectedFile();
if (ff != null) {
file = ff.getAbsolutePath();
}
if (ff == null || !ff.exists()) {
Object[] options = { " OK " };
JOptionPane
.showOptionDialog(
null,
"The selected file does not exist. Please, select an existing file!",
"Error",
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE, null,
options, options[0]);
}
Lo de filtroXML es otra clase que usé para que no se pueda elegir un fichero de otro tipo.... pero no es obligatorio.
Espero que te sirva, un saludo!