Java - JFileChooser

 
Vista:

JFileChooser

Publicado por Julian Osorio Amaya (2 intervenciones) el 18/02/2008 02:00:36
Saludos a todos

estoy realizando una pequenna aplicacion con el JFileChooser, pero no me funciona
no encuentro el error

/*
* Principal.java
*
* Created on February 17, 2008, 4:53 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
/**
*
* @author julsorio
*/
public class Principal extends JFrame {
JMenu menuArchivo;
JMenuBar barraMenu;
JMenuItem itemAbrir;

/** Creates a new instance of Principal */
public Principal() {
barraMenu = new JMenuBar();
menuArchivo = new JMenu("Archivo");
itemAbrir = new JMenuItem("Abrir");

menuArchivo.add(itemAbrir);
barraMenu.add(menuArchivo);
setJMenuBar(barraMenu);

itemAbrir.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evento) {
abrirDirectorio();
}
});

setSize(400, 400);
setVisible(true);
}

private void abrirDirectorio() {
JFileChooser seleccion = new JFileChooser();
}

public static void main(String args[]) {
Principal aplicacion = new Principal();
aplicacion.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}

gracias por su ayuda

Julian Osorio Amaya
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:JFileChooser

Publicado por ideasjava (83 intervenciones) el 18/02/2008 02:26:14
Hola. Aqui te dejamos un metodo que te va a ayudar

public String cuadroGuardarComo(){
JFileChooser selector = new JFileChooser ();
selector.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
selector.setDialogTitle("Guardar Como");
String direccion="";
int opcion1 = selector.showSaveDialog(null);
if (opcion1 == JFileChooser.APPROVE_OPTION){
direccion = selector.getSelectedFile().toString();
}
else{
return "";
}
return direccion;
}

Cualquier duda pregunta.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar