You want use them, and add a filter. For Example:
JFileChooser chooser = new JFileChooser();
// Note: source for ExampleFileFilter can be found in FileChooserDemo,
// under the demo/jfc directory in the Java 2 SDK, Standard Edition.
ExampleFileFilter filter = new ExampleFileFilter();
filter.addExtension("jpg");
filter.setDescription("JPG & GIF Images");
chooser.setFileFilter(filter);
int returnVal = chooser.showSaveDialog(parent);
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose to open this file: " +
chooser.getSelectedFile().getName());
}
this will only show JPG and GIF files. Example stolen from here
Edit: Just so you know ExampleFileFilter implements the abstact class FileFilter
Edit: Since you know the name of the file, you could just have a button that says open and use Runtime.getRuntime.exec('the file to be opened.doc") and that should open it in the appropriate application.
For saving you will still want to prompt them to find out where they want to save it so you would still need the JFileChooser. I would still use a filter, and determine what the file extension will be dynamically if necessary and then do:
JFileChooser chooser = new JFileChooser();
// Note: source for ExampleFileFilter can be found in FileChooserDemo,
// under the demo/jfc directory in the Java 2 SDK, Standard Edition.
String selectedFile = "The suggested save name.";
chooser.setSelectedFile(selectedFile);
ExampleFileFilter filter = new ExampleFileFilter();
String extension = "Do something to find your extension";
filter.addExtension(extension);
filter.setDescription("JPG & GIF Images");
chooser.setFileFilter(filter);
int returnVal = chooser.showSaveDialog(parent);
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose to open this file: " +
chooser.getSelectedFile().getName());
//then write your code to write to disk
}
Hope that helps.