Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnLoad3ActionPerformed(java.awt.event.ActionEvent evt) {
- //se crea el objeto filechiiser
- JFileChooser selector = new JFileChooser();
- selector.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
- int resultado = selector.showOpenDialog(this);
- //se elimina el archivo seleccionado
- if (resultado != JFileChooser.CANCEL_OPTION) {
- File archivo = selector.getSelectedFile(); // obtiene el archivo seleccionado
- if (archivo.delete()){
- JOptionPane.showMessageDialog(null, "El archivo ha sido eliminado correctamente");
- } else {
- JOptionPane.showMessageDialog(null, "El archivo no puede ser eliminado", "Error", JOptionPane.ERROR_MESSAGE);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement