import java.io.*;
import java.awt.*;
import java.awt.event.*;

public class ardisikDosyaOku extends Frame implements ActionListener
{
private TextField accountField,firstNameField,lastNameField,balanceField;
private Button next,done;
private DataInputStream input;

public ardisikDosyaOku()
{
super("Musteri dosyasini oku");
try{
input=new DataInputStream(new FileInputStream("musteri.txt"));
} catch(IOException e) { System.err.println("Dosya acilamadi\n"+e.toString());
System.exit(1);
}
setSize(300,150);
setLayout(new GridLayout(5,2));
add(new Label("Hesap Numarasi :"));
accountField=new TextField();
add(accountField);
add(new Label("isim : "));
firstNameField=new TextField(20);
add(firstNameField);
add(new Label("soyisim : "));
lastNameField=new TextField(20);
add(lastNameField);
add(new Label("Hesaptaki para : "));
balanceField=new TextField(20);
add(balanceField);
next=new Button("bir sonraki hesap");
next.addActionListener(this);
add(next);
done=new Button("cikis");
done.addActionListener(this);
add(done);
setVisible(true);
}

public void readRecord()
{
int account;
String first,last;
double balance;
{
try{
account=input.readInt();
first=input.readUTF();
last=input.readUTF();
balance=input.readDouble();
accountField.setText(String.valueOf(account));
firstNameField.setText(first);
lastNameField.setText(last);
balanceField.setText(String.valueOf(balance));
}
catch(EOFException eof)
{
closeFile();
}
catch(IOException io)
{
System.err.println("Dosyayı24042 okurken hata olustu\n"+io.toString());
System.exit(1);
}
}
}

public void actionPerformed(ActionEvent e)
{
if(e.getSource()==next)
readRecord();
else
closeFile();
}

private void closeFile()
{
try{
input.close();
System.exit(0);
}
catch(IOException e)
{
System.err.println("Dosya Kapama Hatası oluştu\n"+e.toString());
System.exit(1);
}
}

public static void main(String args[])
{
new ardisikDosyaOku();
}
}
