I want to open a directory only not a file

Hai
have a peace day.
I have a question. I'm looking for a dialog box where the user can browse for a directory. All I can find is a dialog box where you can open a file.
Is there one to open a directory? If not, how can I solve this so the user can select a directory?
Thanks.

yes man
sorry for wrong information
do u any sample code
i tried but i can't get it
this is my code
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import javax.swing.*;
public class Test extends JFrame {
JFileChooser chooser = new JFileChooser();
JButton button = new JButton("show file chooser ...");
public Test() {
super("Simple File Chooser Application");
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
contentPane.add(button);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int state = chooser.showOpenDialog(null);
File file = chooser.getSelectedFile();
if(file != null &&
state == JFileChooser.DIRECTORIES_ONLY) {
JOptionPane.showMessageDialog(
null, file.getPath());
else if(state == JFileChooser.CANCEL_OPTION) {
JOptionPane.showMessageDialog(
null, "Canceled");
public static void main(String args[]) {
JFrame f = new Test();
f.setBounds(300,300,350,100);
f.setVisible(true);
f.setDefaultCloseOperation(
WindowConstants.DISPOSE_ON_CLOSE);
f.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
System.exit(0);
}

Similar Messages

  • Lightroom open Photoshop CC but not the files

    When in Lightroom and I click on lets say 3 selected photos and want to open them in Photoshop HDR Pro or as layers, it opens CC fine but not the files. Any ideas? It's the same problem in open in CC as layers or Panorama. None of the files open in CC.

    photosbyfry, jonhillenbrand, Many users have reported the same issue and we are working on a fix.
    In the mean while, i would suggest you to follow the suggestions mentioned under the below article and check if that helps.
    Edit In doesn't work in Lightroom 5.5 from Photoshop CC 2014
    Let me know in case you still get the same issue.
    Regards
    ~ Arpit

  • I want to open a directory not a file

    Hi,
    I have a question. I'm looking for a dialog box where the user can browse for a directory. All I can find is a dialog box where you can open a file.
    Is there one to open a directory? If not, how can I solve this so the user can select a directory?
    Thanks.

    What was wrong with my reply in http://forum.java.sun.com/thread.jspa?threadID=754481&tstart=0 ?

  • When I want to open a PDF document The box that pops up asking if I want to open or save does not come up and it always saves. I need this changed.

    When the window opens to ask if I want to save or not comes up it does so for WORD documents just fine, however, for PDF documents it never asks (it used to). Now it just automatically saves them without asking. I need this changed. I went into applications and changed the setting to always ask but it still is just saving, them no window pops up asking what I want firefox to do with the file like it does with a WORD document. IF I cannot get this resolved I will not be able to continue using firefox. I teach and I have students submitting articles etc in pdf format, I cannot constantly save all pdf files. I just want to open them, review them and then move on. There must be a way to change this so that the window asking what I want firfox to do with the pdf files opens.
    thank you,
    kkwright

    Deleted it, restarted it. tried it again. no change. repeated the whole cycle. no change. thinking about uninstalling and reinstalling, but that won't reallyk change the settings.

  • Firefox does not want to open popup or when I do "file new window" it does not open it too.

    When I click on a link that opens a popup, firefox does not open it. Same for "File> New Window." Then, often after Firefox starts to malfunction and no longer wants to open my bookmarks. I uninstalled and reinstalled firefox, removed all extensions .. But this does not solve my problem. can you help me please?
    Excuse me for my mistakes in English, I am a French person and I try to speak English the best I can so that you can solve my problem. Thank you.
    == This happened ==
    Every time Firefox opened
    == I clic on a link that opens a popu

    Your above posted troubleshooting list shows quite a few extensions.
    Did you really disable all of them and still had the problem?
    See [[Troubleshooting extensions and themes]]
    Which security software (firewall) do you have?
    Some can block pop-ups as well.

  • Ipod is not working anymore i closed it and it does'nt want to open anymore.I am not able to recharge it neither.What is that problem?

    I closed my ipod and it is stuck i cannot open it anymore and not even able to recharge it.Even when i connect it in the computer it does not work.What is the problem with this?

    Try:                           
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try another cable
    - Try on another computer                            
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar                                     

  • Get-ChildItem directory only (not full path) on error output

    Hello,
    I currently use the snippet below to check for folder permissions, it outputs a CSV file which details Category, Reason and TargetName. When I open my error.csv file I see the 3 columns being populated, but how can I get a 4th column with the directory name
    as well? TargetName outputs the complete path to the folder, I want to also include the directory name in the CSV.
    $Path = "C:\test"
    $errors=@()
    get-childitem -recurse $Path -ea silentlycontinue -ErrorVariable +errors | Out-Null
    $errors | select -expand categoryinfo | select category,reason,targetname | export-csv -NoTypeInformation -Delimiter “,” .\error.csv
    Any help would be appreciated. At this point I dont think getting the directory name only is feasible with my method. I've tried many exampled but cant seem to get it. As easy as it may sound.
    Thank you.

    Hi jrv,
    I plugged in your suggestion as follows:
    $Path = "C:\test"
    $errors=@()
    get-childitem $Path -recurse -ea silentlycontinue -ErrorVariable +errors | Out-Null
    $errors | Select TargetObject
    It works but I'm still receiving the full path to the directory. How can I get only the directory name?
    You cannot use $errors.  It is owned by the system and will give you issues.
    If you want a folder name from a full path just use Split-Path
    I took the + out for a reason. It was not a mistake and I changed the name of the variable for a reason.  The custom error variable will fill with all errors and will be created new each time this is run. Try it without changing it incorrectly until
    you understand what is happening.  Don't just blindly do things because it feels good or because you saw a friend do it.
    $Path = 'C:\test'
    get-childitem  $Path -recurse -ea silentlycontinue -ErrorVariable myerrors| Out-Null
    $myerrors| %{Split-Path $_.TargetObject -leaf }
    PowerShell is very easy If you take the time to learn it. If you just guess you will never learn.  Believe me you could never guess how it works short of a course in software engineering.
    ¯\_(ツ)_/¯

  • I WANT to open PDF in Adobe NOT FF but updates force me into FF

    My FF decided on 12/1/2012 to open in browser, overriding my settings. No matter what I do, how I change settings, PDFs open in FF. I even totally uninstalled Acrobat 11 and reinstalled Acrobat 10. Still opens in browser (so does that mean it's FF causing the problem?)
    My settings in FF were to open in Reader, overridden. Changed to save file. Overriden. No
    matter what I do, PDFs open in FF. My settings in FF for years have been to open in Adobe, but now I cannot find the setting!
    So now, haha, PDF opens in FF and FLASH is mucked up. So I've increased the problems and
    spent an hour and a half. Can you help? What am I (or they) doing wrong?

    I solved it as follows:
    in Firefox go to Tools at the top of screen
    then go to Options in the pull down menu
    you will see lists of Contents and Actions
    go down Contents to Portable Document Format (PDF)
    go to Action column click on it a pull down menu will appear
    choose Adobe Reader (default)
    that cured the problem for me.

  • Double clicking TDM file opens DIAdem but does not load file?

    Every other Windows program automatically loads the file when application opens.  Is there a setting for this?
    NOTE:  Using DIAdem 10.2 on Windows Vista Ultimate 64 Bit and Windows XP Pro 32 Bit.

    CaliDevGuy,
    You can try this file. It will update your registry files. I tried it on my computer and it works. You can load it into registry by double-clicking it.
    Regards,
    Song Du
    Application Engineer
    National Instrument
    Regards,
    Song Du
    Systems Software
    National Instruments R&D
    Attachments:
    CB_diadem.zip ‏1 KB

  • Browse for server folder path only (not server file) dialog in TFS 2013

    Hi,
    We are developing an application that requires user to select a folder only and it should not allow user to select file within a TFS project's source control (VersionControl TFS API).
    Thanks in advance.

    Hi TajuddimMD, 
    Thanks for your post.
    To only get the folders under a specific server path, please refer to the below code snippet:
    TfsTeamProjectCollection tfs =
    new
    TfsTeamProjectCollection(new
    Uri("collectionURL"));
    tfs.EnsureAuthenticated();
    VersionControlServer vcs = tfs.GetService<VersionControlServer>();
    ItemSpec[] itemSpecs =
    new
    ItemSpec[1];
              itemSpecs[0] =
    new
    ItemSpec(@"$/teamprojectname/foldername",
    RecursionType.Full);
    ItemSet[] lists = vcs.GetItems(itemSpecs,
    VersionSpec.Latest,
    DeletedState.NonDeleted,
    ItemType.Folder);      
    foreach(var
    item in lists)
              foreach(var
    i in item.Items)
    Console.WriteLine(i.ServerItem);
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • I use gmail on my ipad. Why can't I open any attachments? Not word files, not photos, nothing. Thanks

    I use g-mail on my ipad. I have no trouble receiving mail, but I cannot open any attachments of any kind. Why?

    For Gmail attachments, if they are PDF files (as well as many other formats) when you are viewing them on the iPad in Safari there is an option to "Open in iBooks" just below the tab you have open (at the top of the page).
    From iBooks you can print them to a wireless printer easily.
    Hope this helps.

  • I cannot open rss feeds - Firefox asks whether I want to open or save both rss.php files and application/rss+xml files - any help out there?

    Trying to add feeds to live bookmarks - cannot figure out what setting to change so that when I click on the "subscribe to" button the option to add these feeds to live bookmarks is available.

    Did you find a solution to this yet? I'm trying to do exactly the same thing.

  • Document does not want to open

    Presentation does not want to open. "document does not open due to error"
    What can I do?

    Deleted it, restarted it. tried it again. no change. repeated the whole cycle. no change. thinking about uninstalling and reinstalling, but that won't reallyk change the settings.

  • Problem when open Integration Directory

    Hi :
        when I want to open Integration Directory, there is a message saying " You need to install   Javau2122 WebStart 1.4.2.   ", however I have installed j2sdk-1_4_2_12-windows-i586-p.exe which is the edition of j2sdk 1.4.2 . I am really confused.
        Could you please tell me how to solve it ?

    Hi,
    Could you please tell me which Version of SAP XI/PI you are using.
    if your are using PI 7.0 then the JDK version which you installed is correct.
    Regards,
    Ashok.

  • When I double click a PS file, it opens PS but not the file. Why?

    Since I purchased CS5, I've found that double clicking, or dragging to the Ps (or Ai) icon in the dock will only open the program, but not the file. I then have to go back and double click the file again to bring it up. I've looked in preferences but cannot find a way to resolve this. A friend who also has CS5 does not have this problem.
    Thanks, Neil.

    Have you updated your OS lately?
    Are you on a Mac or a PC?
    That behavior usually is sign of a file vital for Photoshop (and some other Adpobe apps too) missing.
    I've published an old Adobe technote about that here http://www.ninisworld.com/thecorner/tutorials/photoshopopen.html including also the file needed on a Mac.
    If you are on a PC I have no solution to suggest.

Maybe you are looking for