The IFSFileDialog class allows you to traverse the file system and select a file.
This class uses the IFSFile class to traverse the list of directories and files in the integrated file system on the iSeries™ server. Methods on the class allow a Java™ program to set the text on the push buttons of the dialog and to set filters. Note that an IFSFileDialog class based on Swing 1.1 is also available.
You can set filters through the FileFilter class. If the user selects a file in the dialog, the getFileName() method can be used to get the name of the file that was selected. The getAbsolutePath() method can be used to get the path and name of the file that was selected.
The following example shows how to set up a dialog with two filters and to set the text on the push buttons of the dialog.
// Create an AS400 object. AS400 sys = new AS400("mySystem.myCompany.com"); // Create a dialog object setting // the text of the dialog's title // bar and the server to traverse. IFSFileDialog dialog = new IFSFileDialog(this, "Title Bar Text", sys); // Create a list of filters then set // the filters in the dialog. The // first filter will be used when // the dialog is first displayed. FileFilter[] filterList = {new FileFilter("All files (*.*)", "*.*"), new FileFilter("HTML files (*.HTML", "*.HTM")}; dialog.setFileFilter(filterList, 0); // Set the text on the buttons of // the dialog. dialog.setOkButtonText("Open"); dialog.setCancelButtonText("Cancel"); // Show the dialog. If the user // selected a file by pressing the // Open button, get the file the // user selected and display it. if (dialog.showDialog() == IFSFileDialog.OK) System.out.println(dialog.getAbsolutePath());