• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Only accept a file type in JFileChooser ?

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
make ur own class extenidng
javax.swing.filechooser.FileFilter

like

now add this filter to ur filechooser

Hope this will help....
 
Steven Zeng
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In fact i want that in JFileChooser user can not select "all files *.*" in file type ComBoBox. However thanks for your reply
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic