We can then call either showOpenDialog or showSaveDialog . The former displays
a dialogue box with ‘Open’ and ‘Cancel’ buttons, while the latter displays a
dialogue box with ‘Save’ and ‘Cancel’ buttons. Each of these methods takes a single
argument and returns an integer result. The argument specifies the JFileChooser ’s
parent component, i.e. the window over which the dialogue box will be displayed.
For example: