Finding a file path in java gui using File
<p>I'm supposed to create a gui that reads in a file and uses the path
that you entered in to do so. How can I make this work from the code I
have given. I need to take the input from the javapath variable and 
use it to <code>File inFile = new File (getJavapath());</code></p>

<pre><code>import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.logging.*;
import javax.swing.*;


public class P_Supplemental_10 extends JFrame {

private JPanel javapanel = new JPanel();
private JButton javareader = new JButton("Click here to get file");
private JTextField javapath = new JTextField();
private JLabel javalabel = new JLabel("Enter file name here; ");
private JTextArea javacontents = new JTextArea();

P_Supplemental_10() {

    this.setLayout(new BorderLayout(5, 10));
    javapanel.setLayout(new GridLayout(1,2));
    javapanel.add(javalabel);
    javapanel.add(javapath);
    add(javapanel,BorderLayout.NORTH);
    add(javacontents,BorderLayout.CENTER);

    add(javareader,BorderLayout.SOUTH);
    javareader.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent evt){

                        jbtReadFileActionPerformed(evt);
                    }
    });

}//end of constructor


    private void jbtReadFileActionPerformed(ActionEvent evt){
    try {
        File inFile = new File (getJavapath());

        Scanner input = new Scanner (inFile);
        String fileContents = "";
        while(input.hasNext()){
            fileContents += input.nextLine() + "\n";
        }
            getJavacontents().setText(fileContents);



    } catch (FileNotFoundException ex) {
        Logger.getLogger(P_Supplemental_10.class.getName()).log(Level.SEVERE, null, ex);
    }
    }

public static void main(String[] args){
        P_Supplemental_10 frame = new P_Supplemental_10();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("P_Supplemental_10");
    frame.setSize(625, 60);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);






}//end of main

/**
 * @return the javapanel
 */
public JPanel getJavapanel() {
    return javapanel;
}

/**
 * @param javapanel the javapanel to set
 */
public void setJavapanel(JPanel javapanel) {
    this.javapanel = javapanel;
}

/**
 * @return the javareader
 */
public JButton getJavareader() {
    return javareader;
}

/**
 * @param javareader the javareader to set
 */
public void setJavareader(JButton javareader) {
    this.javareader = javareader;
}

/**
 * @return the javapath
 */
public JTextField getJavapath() {
    return javapath;
}

/**
 * @param javapath the javapath to set
 */
public void setJavapath(JTextField javapath) {
    this.javapath = javapath;
}

/**
 * @return the javalabel
 */
public JLabel getJavalabel() {
    return javalabel;
}

/**
 * @param javalabel the javalabel to set
 */
public void setJavalabel(JLabel javalabel) {
    this.javalabel = javalabel;
}

/**
 * @return the javacontents
 */
public JTextArea getJavacontents() {
    return javacontents;
}

/**
 * @param javacontents the javacontents to set
 */
public void setJavacontents(JTextArea javacontents) {
    this.javacontents = javacontents;
}

}// end of class
</code></pre>
