So for a project I'm making I need to import pictures. But the only problem is that my filter, filters everything and I never recieve A file back
public class FileChooser extends JPanel{
public FileChooser(){
JFileChooser fileopen=new JFileChooser();
FileFilter filter=new FileNameExtensionFilter("jpg files","jpg");
fileopen.addChoosableFileFilter(filter);
int ret =fileopen.showDialog(null,"Open file");
if (ret==JFileChooser.APPROVE_OPTION){
File[] picture=fileopen.getSelectedFiles();
System.out.println(picture[0].getName());
}
}
}