The IFSFileDialog class is a dialog that allows the user to traverse the directories of the integrated file system on the server and select a file. The caller can set the text on the buttons on the dialog. In addition, the caller can use FileFilter objects, which allow the user to limit the choices to certain files.
If the user selects a file in the dialog, use the getFileName() method to get the name of the selected file. Use the getAbsolutePath() method to get the full path name of the selected file.
The following example sets up an integrated file system file dialog with two file filters:
// Create a IFSFileDialog object // setting the text of the title bar. // Assume that "system" is an AS400 // object and "frame" is a JFrame // created and initialized elsewhere. IFSFileDialog dialog = new IFSFileDialog (frame, "Select a file", system); // Set a list of filters for 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")}; // Then, set the filters in the dialog. dialog.setFileFilter (filterList, 0); // Set the text on the buttons. dialog.setOkButtonText ("Open"); dialog.setCancelButtonText ("Cancel"); // Show the dialog. If the user // selected a file by pressing the // "Open" button, then print the path // name of the selected file. if (dialog.showDialog () == IFSFileDialog.OK) System.out.println (dialog.getAbsolutePath ());Example
Present an IFSFileDialog and print the selection, if any.
Figure 1 shows the IFSFileDialog graphical user interface component:
Figure 1: IFSFileDialog GUI component