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");
}
}
}