How to select default FileFilter when creating a JFileChooser dialog?

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









Related Tutorials/Questions & Answers:
How to select default FileFilter when creating a JFileChooser dialog?
Select DropDown Default
Advertisements
How to open a file in java using JFileChooser
ModuleNotFoundError: No module named 'Dialogs'
how I do select from select in hql
JFileChooser - Swing AWT
JFileChooser - Java Beginners
Using a JFileChooser - Java Beginners
How to use select Statement in MySQL?
ModuleNotFoundError: No module named 'pyqt5-file-dialogs'
ModuleNotFoundError: No module named 'pyqt5-file-dialogs'
ModuleNotFoundError: No module named 'botbuilder-dialogs'
ModuleNotFoundError: No module named 'difficult-dialogs'
how to operate on select box using ajax in struts2?
how to creating hbm files in hibernate using Myeclipse
How to change MySQL default port Windows?
How to change MySQL default port Windows?
how to operate on select box using ajax in struts2?
How to assign a default value to text box in netbeans
ModuleNotFoundError: No module named 'botbuilder-community-dialogs-prompts'
how to select second combobox value .
how to by default chceckbox button is selected in struts
How to configure mvc:default-servlet-handler tag?
how to display default radio button in struts2.0 for first time login - Struts
How to Creating Pop Up Menu in PHP?
How to change default MySQL port in linux?
How to change focus among multiple select boxes?
How to threow timeout exception when DB is not responding
How to threow timeout exception when DB is not responding
Version of com.robbypond>material-dialogs dependency
Version of com.tinesoft>gwt-dialogs dependency
how to select the row value that was retrived from the database ?
how to select the row value that was retrived from the database ?
jQuery 'select' form event
How to implement ajax in struts2 to operate on select box in jsp
What is the default session time in php and how can I change it?
How to align the select tags in a single column.
wait until a file is opened using JFileChooser
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE123 is released. Learn to use org-openide-dialogs version RELEASE123 in Maven based Java projects
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE124 is released. Learn to use org-openide-dialogs version RELEASE124 in Maven based Java projects
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE160 is released. Learn to use org-openide-dialogs version RELEASE160 in Maven based Java projects
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE122 is released. Learn to use org-openide-dialogs version RELEASE122 in Maven based Java projects
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE121 is released. Learn to use org-openide-dialogs version RELEASE121 in Maven based Java projects
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE120-u1 is released. Learn to use org-openide-dialogs version RELEASE120-u1 in Maven based Java projects
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE120 is released. Learn to use org-openide-dialogs version RELEASE120 in Maven based Java projects
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE113 is released. Learn to use org-openide-dialogs version RELEASE113 in Maven based Java projects
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE130 is released. Learn to use org-openide-dialogs version RELEASE130 in Maven based Java projects
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE126 is released. Learn to use org-openide-dialogs version RELEASE126 in Maven based Java projects
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE120-1 is released. Learn to use org-openide-dialogs version RELEASE120-1 in Maven based Java projects
Maven dependency for org.netbeans.api - org-openide-dialogs version RELEASE150 is released. Learn to use org-openide-dialogs version RELEASE150 in Maven based Java projects

Ads