Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is no problem with MyComputer because it appears in the list with or without the null condition. Please check how <code>FileFilter</code> works <a href="http://docs.oracle.com/javase/6/docs/api/javax/swing/filechooser/FileFilter.html" rel="nofollow" title="FileFilter documentation">here</a> .</p> <p>As stated in the documentation: </p> <blockquote> <p>"A <code>FileFilter</code> can be set on a <code>JFileChooser</code> to keep unwanted files from appearing in the directory listing".</p> </blockquote> <p>So if <code>accept()</code> method returns <code>true</code>, means that the passed in <code>File</code> will appear in the list, false otherwise.</p> <p>The application hangs because what MyComputer may contain. Put a log like below: </p> <pre><code>public boolean accept(File f) { System.out.println("File is : " + f); if(f.isDirectory()) return true;..... </code></pre> <p>Rerun the application without the null condition, in order to reproduce the issue, and update your question with the output you see. The answer will be there.</p> <p><strong>Edit:</strong> I simulated the behaviour you have and I get below output, please update your question with similar output, at least the last 10 lines:</p> <pre><code>File is : Computer File is : Network File is : Libraries File is : Homegroup File is : C:\ File is : E:\ File is : F:\ Exception in thread "Basic L&amp;F File Loading Thread" java.lang.NullPointerException: at Main$1.accept(Main.java:17) at javax.swing.JFileChooser.accept(JFileChooser.java:1617) at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run0(BasicDirectoryModel.java:252) at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:228) </code></pre> <p>I hope this helps.</p> <p>P.S.: an easier way to do the filtering is to use <code>FileNameExtensionFilter</code> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload