I made a simple application to open only XML files using JFileChooser. How can I show the open dialog again and again until I open correct XML file or press cancel button?
I made a simple application to open only XML files using JFileChooser . How
Share
You could add a file filter to the file chooser that checks whether the file is an xml file.
When the user has selected a file you check that file’s content and if it isn’t valid you just open the filechooser again, e.g. in a loop that exits when either the file is valid or the user selected the cancel option.
Basically the loop might look like this (that’s quickly written and might contain errors):
This loop does the following: