aspose file tools*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
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: 2578

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://aspose.com/file-tools
 
subject: Only accept a file type in JFileChooser ?