Results 1 to 2 of 2

Thread: File location

  1. #1

    Thread Starter
    Hyperactive Member Greyskull's Avatar
    Join Date
    Dec 2003
    Location
    somewhere in England
    Posts
    382

    File location

    hello,

    the following code is an extract of my code

    Code:
    public FileChooserDemo() 
    {
            fc = new JFileChooser();
    
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            //fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    
            openButton = new JButton("Open a File...");
            openButton.addActionListener(this);
    }
    public void actionPerformed(ActionEvent e) 
    {
            if (e.getSource() == openButton) {
                int returnVal = fc.showOpenDialog(FileChooserDemo.this);
    
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    File file = fc.getSelectedFile();            
        }
    The jframe is set-up so that it contains a jtextarea and a jbutton (open file).
    How can i get the path of the file(picture - ill expand the code so that it will only select pictures) selected by the user and place the path onto the textarea?

    Thanks for any help and/or suggestions,
    Please go to the Thread Tools menu and click Mark Thread Resolved when your post is answered
    If someone helped you today then please consider rating their post.

  2. #2
    Frenzied Member
    Join Date
    Feb 2008
    Location
    Texas
    Posts
    1,288

    Re: File location

    fc.getSelectedFile().getPath();

    Justin Fox
    You down with OOP? Yeah you know me!
    MCAD and MCMICKEYMOUSE (vb.net)

    ----

    If it even kinda helps... rate it : )

    Edit a Multi-page .tif file and save.

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