Read Random File
Read Random File
java
// This program reads a random-access file sequentially and
// displays the contents one record at a time in text fields.
import java.io .*;
import java. awt .*:
import java. awt. event .*;
import java. text. DecimalFormat;
import javax. swing.";
public class ReadRandomFile extends JFrame {
private BankUI userInterface;
private RandomAccessFile input;
private JButton next, open;
public ReadRandomFile()
super( "Read Client File" )
userInterface = new BankUI();
next = userInterface.getDoTask ();
next. setText( "Next" );
next. setEnabled( false );
next. addActionListener (
new ActionListener () {
public void actionPerformed( ActionEvent e ) {
readRecord() ;
7
);
addwindowListener (
new WindowAdapter () {
public void windowClosing( WindowEvent e ) {
if ( input != null ) {
closeFile();
3
else
System. exit( 0 ); }
open = userInterface. getDoTask2();
open. setText( "Read File" );
open. addActionListener (
new ActionListener () {
public void actionPerformed( ActionEvent e ) {
openFile();
getContentPane() . add( userInterface );
setSize( 300, 150 ); show();