title: Java: Show "*.java" in "File of type" as default in fileChooser
body: <p>I have one problem in fileChooser.</p>
  
  <p>when fileChooser window come then I want to show .java as a default name in "File of type" and in list I want to show  *.java, *.class, All File respectively.</p>
  
  <p>For this I use following code:</p>
  
  <pre><code>public class Main {
  public static void main(String[] argv) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  JFileChooser fileChooser = new JFileChooser(new File("."));
  fileChooser.addChoosableFileFilter(new MyFilter());
  fileChooser.addChoosableFileFilter(new MyFilter2());
  fileChooser.setAcceptAllFileFilterUsed(true);
  fileChooser.showOpenDialog(null);
  System.out.println(fileChooser.getSelectedFile());
  }
  }
  
  class MyFilter extends javax.swing.filechooser.FileFilter {
  public boolean accept(File file) {
  String filename = file.getName();
  return filename.endsWith(".java");
  }
  
  public String getDescription() {
  return "*.java";
  }
  }
  
  class MyFilter2 extends javax.swing.filechooser.FileFilter {
    public boolean accept(File file) {
      String filename = file.getName();
      return filename.endsWith(".class");
    }
  
    public String getDescription() {
      return "*.class";
    }
  }
  </code></pre>
  
  <p>but in this code by default nothing is there in "File of type" and in the list it show  *.java, *.class, All File respectively.But I want to show *.java name as a default name in "File of type".</p>
  
  <p>When I change this code and put <strong>fileChooser.setAcceptAllFileFilterUsed(true);</strong> above to <strong>fileChooser.addChoosableFileFilter(new MyFilter());</strong> then All File show defaule name in "File of type".</p>
  
  <p>If you save a text file in text editor then there <strong>Text Documents(<em>.txt)</strong> show as a default and in list Text Documents(</em>.txt) and All File is there.</p>
  
  <p>I want same thing in my application.</p>
  
  <p>I am also attaching photo which give clear information what I want:</p>
  
  <p>My application work like this:</p>
  
  <p><img src="https://i.stack.imgur.com/G18R0.jpg" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/qhk0G.jpg" alt="enter image description here"></p>
  
  <p>But I want like this:</p>
  
  <p><img src="https://i.stack.imgur.com/VrYbh.jpg" alt="enter image description here"></p>