title: How to filter file type in FileDialog?
body: <p>I am using FileDialog for saving and loading in a Java program.</p>
  
  <p>How can I filter the dropdown list to specify the file type as "JPG" or "JPEG" etc. ?</p>
  
  <p>I have tried the following code, but it seems to have no effect.</p>
  
  <p>Are there any other ways of doing this ?</p>
  
  <pre><code>public void actionPerformed(ActionEvent e) {
              FileDialog saveFileDialog = new FileDialog(new Frame(), "Save", FileDialog.SAVE);
  
              saveFileDialog.setFilenameFilter(new FilenameFilter(){
                  @Override
                  public boolean accept(File dir, String name) {
                      return name.endsWith(".jpg") || name.endsWith(".jpeg");
                  }
              });
              saveFileDialog.setFile("Untitled.jpg");
              saveFileDialog.setVisible(true);
          }
  </code></pre>