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?
How to open a file in java using JFileChooser
Advertisements
Select DropDown Default
ModuleNotFoundError: No module named 'Dialogs'
how I do select from select in hql
JFileChooser - Swing AWT
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'
JFileChooser - Java Beginners
Using a JFileChooser - Java Beginners
How to use select Statement in MySQL?
How to change MySQL default port Windows?
How to change MySQL default port Windows?
ModuleNotFoundError: No module named 'botbuilder-community-dialogs-prompts'
How to assign a default value to text box in netbeans
how to operate on select box using ajax in struts2?
how to by default chceckbox button is selected in struts
How to configure mvc:default-servlet-handler tag?
how to select second combobox value .
how to operate on select box using ajax in struts2?
how to creating hbm files in hibernate using Myeclipse
How to change default MySQL port in linux?
how to display default radio button in struts2.0 for first time login - Struts
Version of com.robbypond>material-dialogs dependency
Version of com.tinesoft>gwt-dialogs dependency
How to change focus among multiple select boxes?
How to Creating Pop Up Menu in PHP?
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 ?
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 RELEASE125 is released. Learn to use org-openide-dialogs version RELEASE125 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 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 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 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 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 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 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 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 RELEASE122 is released. Learn to use org-openide-dialogs version RELEASE122 in Maven based Java projects
What is the default session time in php and how can I change it?
Java Dialogs - Swing AWT
ModuleNotFoundError: No module named 'cornel-movie-dialogs-corpus-storm'
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

Ads