To create a custom file filter to show only specific files in a file chooser dialog, subclass javax.swing.filechooser.FileFilter and use this with the chooser.
Tutorial Details:
By default, a file chooser shows all user files and directories in a file chooser dialog, with the exception of "hidden" files in Unix (those starting with a '.').
To create a custom file filter to show only specific files in a file chooser dialog, subclass javax.swing.filechooser.FileFilter and use this with the chooser (see JFileChooser).
Because there is an interface (java.io.FileFilter) and a class (javax.swing.filechooser.FileFilter), use the fully qualified name to prevent conflicts in any code that also includes java.io.*.
Creating a chooser FileFilter
Create a class that extends javax.swing.filechooser.FileFilter, and define two methods: accept and getDescription.
Rate Tutorial: http://www.roseindia.net/java/java-tips/io/10file/38chooser-filefilter.shtml
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: javax.swing.filechooser.FileFilter
View Tutorial: javax.swing.filechooser.FileFilter
Related
Tutorials:
|