Results 1 to 2 of 2

Thread: File Chooser Question

  1. #1

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    File Chooser Question

    Here is the code I am using now:

    Code:
                JFrame frame = new JFrame();
        
        
        String filename = "Desktop";
        JFileChooser fc = new JFileChooser(new File(filename));
        
        
    
       fc.setFileFilter(new FileFilter() {
       public String getDescription() { return "CSV file"; }
       public boolean accept(File f) {
          if(f.isDirectory()) return true;
          if(f.getName().endsWith(".csv")) return true;
          return false;
        }
       });
    
       
        
        // Show open dialog; this method does not return until the dialog is closed
        fc.showOpenDialog(frame);
        file1 = fc.getSelectedFile();

    How do I edit this code so that when the filechooser pops up it automatically goes to the Desktop folder. I am on a mac.

    Thanks

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: File Chooser Question

    You can use System.getProperty to construct the path
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width