File Chooser Example
We assume the chooser is displayed by a handler for an action event, perhaps an open or save item in a menu.
A file chooser object is created, then some attributes are set for it: here we only set the current directory. In general one can also set default files, and filters for file extensions, etc.
The chooser object with these attributes may be saved and reused in several places.
A dialog window is created by the showOpenDialog() method. There is also a showSaveDialog() method.
The selected file is returned by the getSelectedFile() method.