Total members 11894 |It is currently Sun Nov 24, 2024 2:46 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Code for File Filters in JFileChooser and how to use File Chooser in java:
-----------------------------------------

This code, will create a file filter for you, you must only edit two areas. You will recognize which ones immediately. I will point it out nonetheless.
After creating one or two or as many filters as you want, you can run your JFileChooser, either OpenDialog or SaveDialog, and you will have filters.

java code
import javax.swing.filechooser.FileFilter;
loadPub.addChoosableFileFilter(new FileFilter() //adds new filter into list
{
String description = "Publisher Files (*.pbb)";
/*change text within "" to text you want to appear in File Chooser*/

String extension = "pbb";
/*change text within "" for Filter you want created*/
public String getDescription()
{
return description;
}
public boolean accept(File f)
{
if(f == null) return false;
if(f.isDirectory()) return true;
return f.getName().toLowerCase().endsWith(extension);
}
});



Remember, if you want more than one filter, simply duplicate the above code, but changing the text within the " " to the new desired filter. If for any reason this code is altered, please notify me, or place a comment about it being altered and why.



_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 109
Have thanks: 5 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Create Custom Filters For JFileChooser!!!!
 Create a Custom Log in java     -  
 Create Custom Brushes in Photoshop     -  
 How to Load Files using JFileChooser!!     -  
 Using Filters Effects     -  
 stream get filters     -  
 image processing filters project     -  
 custom cursor in javascript     -  
 Image Custom Filter In Java     -  
 dynamically load a custom user control with a param construc     -  
 Image-Viewer-Image Processing-Filters-Noise-enhancements     -  



Topic Tags

Java Swing
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com