![]() |
Display a file from a FileDialog
In this Magercise, you will create an applet that creates and shows a FileDialog. It should use the file property of the FileDialog bean to obtain the selected file name and display it in a textfield on the applet.
Work LocationPerform all work for this magercise in VisualAge project MageLang Magercises, package magercises.displayfiledialog. If this project does not appear in your Workspace add it from the repository (if it exists there) or create a new project using this name. Tasks
Perform the following tasks:
Create the connection to show the file dialog when the user presses the button. Create the connection to dispose of the file dialog. You may wonder why the Button both shows and disposes of the file dialog. Here's a brief synopsis of what happens. First, notice that there are two connections that both have actionPerformed(java.awt.event.ActionEvent) as the source event. One connection has the show() method as its target, and the other has the dispose() method as its target. Once the show() method is called in the file dialog, the file dialog has control until the user selects the Open button or the Cancel button. After the user has selected one of these buttons, control returns to the DisplayFileDialog class, and the next action it takes is to hide the file dialog by calling its dispose() method. Create the connection to set the TextField to the file that was chosen.
|
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |