How to select default FileFilter when creating a JFileChooser dialog?

Ads
 

How to select default FileFilter when creating a JFileChooser dialog?

Hi,

In my swing application I want my application to open the my specific directory say "c:\mydirectory" when browse button is clicked.

How to select default FileFilter when creating a JFileChooser dialog?

Thanks

View Answers

August 21, 2012 at 12:48 PM

Hi,

Following code can be used:

JFileChooser c = new JFileChooser();
c.setFileSelectionMode(c.DIRECTORIES_ONLY);
String defaultDirectoryPath = "C:\\mydirectory";
c.setSelectedFile(new File(defaultDirectoryPath));

Thanks

Ads









Related Tutorials/Questions & Answers:
How to select default FileFilter when creating a JFileChooser dialog?
How to open a file in java using JFileChooser
Advertisements
Select DropDown Default
how I do select from select in hql
How to use select Statement in MySQL?
ModuleNotFoundError: No module named 'Dialogs'
how to creating hbm files in hibernate using Myeclipse
how to select second combobox value .
how to operate on select box using ajax in struts2?
how to operate on select box using ajax in struts2?
How to change MySQL default port Windows?
How to change MySQL default port Windows?
How to Creating Pop Up Menu in PHP?
How to assign a default value to text box in netbeans
how to by default chceckbox button is selected in struts
How to configure mvc:default-servlet-handler tag?
How to change focus among multiple select boxes?
How to change default MySQL port in linux?
ModuleNotFoundError: No module named 'botbuilder-dialogs'
ModuleNotFoundError: No module named 'difficult-dialogs'
ModuleNotFoundError: No module named 'pyqt5-file-dialogs'
ModuleNotFoundError: No module named 'pyqt5-file-dialogs'
How to threow timeout exception when DB is not responding
How to threow timeout exception when DB is not responding
how to select the row value that was retrived from the database ?
how to select the row value that was retrived from the database ?
How to implement ajax in struts2 to operate on select box in jsp
How to align the select tags in a single column.
How to read excel contents when uploaded
ModuleNotFoundError: No module named 'botbuilder-community-dialogs-prompts'
While creating a jar how to add MySQL database to project

Ads