How to save image inside a project folder?

0

I am working on a project in which you have the option to register products, each product has an image, the question is that I know how I can save that image obtained in a folder within the same project.

Here is the method where I capture and visualize the image.

 private void btncargarimagenActionPerformed(java.awt.event.ActionEvent evt) {                                                

    int opcion = jf.showDialog(null, "Seleccionar Imagen");

    if (opcion == JFileChooser.APPROVE_OPTION) {
        archivo = jf.getSelectedFile();

        if (archivo.getName().endsWith("jpg") || archivo.getName().endsWith("png")
                || archivo.getName().endsWith("JPG") || archivo.getName().endsWith("PNG")) {

            ImageIcon imagen = new ImageIcon("" + archivo);
            Icon icono = new ImageIcon(imagen.getImage().getScaledInstance(lblfoto.getWidth(), lblfoto.getHeight(), Image.SCALE_DEFAULT));
            lblfoto.setIcon(icono);               

        } else {
            JOptionPane.showMessageDialog(null, "Archivo No Compatible");
        }
    }
}                                               
    
asked by Steven Camargo 21.05.2018 в 22:54
source

0 answers