I have a JFileChooser and Im able to print the Absolute Path in console.
I need to show the FilePath in a Text field as soon as the User selects the file.
Below is the code please let me know how to do it.
public void actionPerformed(ActionEvent ae) {
JFileChooser fileChooser = new JFileChooser();
int showOpenDialog = fileChooser.showOpenDialog(frame);
if (showOpenDialog != JFileChooser.APPROVE_OPTION) return;
Please let me know if you need any other details.
You need to listen to the changes that occur when using the JFileChooser, see this snipet of code:
All you need to do inside the first condition is set the value of your textfield to match the new selected filename. See this example:
Or just
It is the method getName() from class File that will give you what you need.
Help your self from de API docs to see what each method does.