This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Only accept a file type in JFileChooser ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Only accept a file type in JFileChooser ?" Watch "Only accept a file type in JFileChooser ?" New topic
Author

Only accept a file type in JFileChooser ?

Steven Zeng
Ranch Hand

Joined: Jan 15, 2002
Posts: 41
Hi all,
Would you please tell me how to let a JFileChooser only accept one file type for example "*.jar"(I know FileFilter). In fact, I don't want that user can select "all files" in JFileChooser, but I don't know how to disable the JCombobox.
Thanks ahead!


SCJP2
aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
make ur own class extenidng
javax.swing.filechooser.FileFilter

like

now add this filter to ur filechooser

Hope this will help....


Regards<br />Aminur
Steven Zeng
Ranch Hand

Joined: Jan 15, 2002
Posts: 41
In fact i want that in JFileChooser user can not select "all files *.*" in file type ComBoBox. However thanks for your reply
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2573

Originally posted by Steven Zeng:
In fact i want that in JFileChooser user can not select "all files *.*" in file type ComBoBox. However thanks for your reply

Use -
fileChooser.setAcceptAllFileFilterUsed(false);
HTH,
- Manish
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Only accept a file type in JFileChooser ?
 
Similar Threads
JFileChooser
problem with file chooser
JFileChooser
saving a text file using JFileChooser
Filter in JFileChooser