Java Reference
In-Depth Information
In order to read an individual record, we shall defi ne a method called readRecord that
reads in the surname, fi rst name(s) and examination mark for an individual student.
Before looking at the code, it is probably useful to look ahead and see what the
intended output should look like. In order that the JFileChooser object may be
viewed as well, the screenshot in Fig. 4.5 shows the screen layout after one fi le has
been opened and then the 'Open File' button has been clicked on by the user.
Fig. 4.5
A JFileChooser object being used to select a fi l e
The code for this application is shown below. If the reader wishes to create a
serial fi le for testing this program, this may be done very easily by using any text
editor to enter the required three fi elds for each of a series of students (each fi eld
being followed by a carriage return).
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class UseFileChooser extends JFrame
implements ActionListener
Search WWH ::

Custom Search