I want to know if there's a way to get the text the user writes in a JFileChooser
after pressing "accept" (I removed the confirm and cancel buttons) like a text field (.getText()
).
Here is an example I wrote:
JFileChooser x=new JFileChooser();
int returnVal=x.showOpenDialog(this);
File file=x.getSelectedFile();
System.out.println(file.getName());
Even though the file isn't an actual file it would still print out what is in the box when you call file.getName()
. When I typed a random string of characters it returned the string of characters even though it's not a file.