• 0

JFileChooser(); a lil stuck


Question

JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle("Browse the folder to process");
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.setAcceptAllFileFilterUsed(false);

if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
System.out.println("getCurrentDirectory(): "+ chooser.getCurrentDirectory());
System.out.println("getSelectedFile() : "+ chooser.getSelectedFile());
} else {
System.out.println("No Selection ");
}

hello,

 

I am currently programming on a mac (os, 10.9.2), using eclipse trying to access a usb drive plugged into my mac, but I cannot see it using this code... I can see everything on my local machine but no drives, any help?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle("Browse the folder to process");
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.setAcceptAllFileFilterUsed(false);

if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
System.out.println("getCurrentDirectory(): "+ chooser.getCurrentDirectory());
System.out.println("getSelectedFile() : "+ chooser.getSelectedFile());
} else {
System.out.println("No Selection ");
}

hello,

 

I am currently programming on a mac (os, 10.9.2), using eclipse trying to access a usb drive plugged into my mac, but I cannot see it using this code... I can see everything on my local machine but no drives, any help?

 

 

Have you tried looking in the {hard-drive-name}/Volumes directory?

Link to comment
Share on other sites

  • 0

Have you tried looking in the {hard-drive-name}/Volumes directory?

yes lol, sadly maybe I did not explain my self properly (i have a habit of this) I can obviously find my drives if I go through the very long and painful way, but it does not show up in the top drop down it only shows my home DIR and C drive was just wondering if maybe I am being silly

Link to comment
Share on other sites

  • 0

yes lol, sadly maybe I did not explain my self properly (i have a habit of this) I can obviously find my drives if I go through the very long and painful way, but it does not show up in the top drop down it only shows my home DIR and C drive was just wondering if maybe I am being silly

No, that's it's intended functionality, the rest are just mounted into the existing filesystem - so you're not doing anything wrong, it's behaving exactly as it has been designed to do :)

Link to comment
Share on other sites

  • 0

No, that's it's intended functionality, the rest are just mounted into the existing filesystem - so you're not doing anything wrong, it's behaving exactly as it has been designed to do :)

ah ok thank you :P

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.