import javax.swing.*; import javax.swing.filechooser.FileFilter; import java.io.*; public class Failivalik2{ public static void main(String argumendid[]){ JFileChooser valija=new JFileChooser(new File(".")); valija.addChoosableFileFilter(new Pildifilter()); valija.showDialog(new JFrame(), "Vali fail"); System.out.println("Valiti "+valija.getSelectedFile()); } } class Pildifilter extends FileFilter{ public boolean accept(File f){ String failinimi=f.getName(); if(failinimi.endsWith(".gif")|failinimi.endsWith(".jpg")) return true; else return false; } public String getDescription(){ return "Pildifailid "; } }