Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2007

Tip: Looking for answers? Try searching our database.

Removing "All Files" option from FileType of JFileChooser

Thread view: 
urpriya@gmail.com - 23 Feb 2007 06:22 GMT
How to remove "All Files" option from JFileChooser? OR How can i
diable the selection of file type of All FIles?

I want to select only image files form the JFileChooser. How can i
implement this feature?
Srik - 23 Feb 2007 09:28 GMT
I think the question here is When we apply a filter to the
JFileChooser, say to select image files, when we do open dialog ,we
can see the filter - image files as well as "All files". All files
would come all the time. If "All files" is also displayed then there
is no point in applying the filter, since the user can very well
select "All files" all the time. Even i am facing this problem. Any
help??
Thomas A. Russ - 23 Feb 2007 17:21 GMT
> I think the question here is When we apply a filter to the
> JFileChooser, say to select image files, when we do open dialog ,we
[quoted text clipped - 3 lines]
> select "All files" all the time. Even i am facing this problem. Any
> help??

Why is this a problem?

Having the extra flexibility is a benefit to the user interface, because
you can end up in situations where files happen not to be named
correctly.  That is why you shouldn't remove the "All Files" filter
option.  I think it is a mistake to assume that you have complete
control of the environment in which your application can run, or that
the software is smarter than the user.

By all means, add the image file filter and use that as the default
setting, but leave the option to select all files in as well.  You will
have a more robust user interface, and your users will be thankful.

I don't really see any advantage to disabling the all files option,
since you would still need to handle mal-formed or mis-named files when
you try to load image files anyway.  So if you are worried about someone
deliberately changing the filter and choosing a non-image file, you
would already have the code in place to trap the problem and complain.
You need that code anyway, so it isn't any more work to make the
interface flexible.

Signature

Thomas A. Russ,  USC/Information Sciences Institute

Michael Dunn - 23 Feb 2007 09:31 GMT
> How to remove "All Files" option from JFileChooser?

fileChooser.setAcceptAllFileFilterUsed(false);
Srik - 23 Feb 2007 10:23 GMT


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.