Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- btnSeleccionar.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- // Creamos el objeto JFileChooser
- JFileChooser fc = new JFileChooser();
- // Indicamos lo que podemos seleccionar
- fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
- // Creamos el filtro
- FileNameExtensionFilter filtro = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "bmp");
- // Le indicamos el filtro
- fc.setFileFilter(filtro);
- // Abrimos la ventana, guardamos la opcion seleccionada por el usuario
- int seleccion = fc.showOpenDialog(contentPane);
- // Si el usuario, pincha en aceptar
- if (seleccion == JFileChooser.APPROVE_OPTION) {
- // Seleccionamos el fichero
- File ficheros = fc.getSelectedFile();
- @SuppressWarnings("unused")
- Image image = new Image(ficheros.toString());
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement