import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GUI extends JFrame implements ActionListener
{
// Anfang Attribute
bankacc_rc Test = new bankacc_rc(15000, 5000, 1234, -5000, 25000);
private JTextField tfBetrag, tfPIN, tfKontostand;
private JTextArea tfSystem;
private int Einzahlung, Auszahlung, Kontostand = Test.getKontostand(), Limit = Test.getLimit(), Geheimzahl = Test.getGeheimzahl(), Dispo = Test.getDispo(), Auszahlungen, LimitProTag = Test.getLimitProTag();
private JButton btAbheben = new JButton();
private JButton btBestätigen = new JButton();
private JButton btEinzahlen = new JButton();
// Ende Attribute
//Konstruktor
public GUI()
{
super("Bank Account");
this.getContentPane().setBackground(Color.lightGray);
this.getContentPane().setLayout(null);
//Einzahlen-Button
JButton btEinzahlen = new JButton("Einzahlen");
btEinzahlen.setBounds (20, 120, 120, 30);
btEinzahlen.setBackground(Color.green);
btEinzahlen.addActionListener(this);
this.getContentPane().add(btEinzahlen);
//Auszahlen-Button
JButton btAbheben = new JButton("Abheben");
btAbheben.setBounds (20, 160, 120, 30);
btAbheben.setBackground(Color.green);
btAbheben.addActionListener(this);
this.getContentPane().add(btAbheben);
//Bestätigen-Button
JButton btBestätigen = new JButton("Bestätigen");
btBestätigen.setBounds (20, 200, 120, 30);
btBestätigen.setBackground(Color.green);
btBestätigen.addActionListener(this);
this.getContentPane().add(btBestätigen);
//Betrag-Label
JLabel lbBetrag = new JLabel ("Betrag:");
lbBetrag.setBounds (110, 40, 90, 30);
this.getContentPane().add (lbBetrag);
//Kontostand-Label
JLabel lbKontostand = new JLabel ("Kontostand");
lbKontostand.setBounds (440, 35, 90, 30);
this.getContentPane().add (lbKontostand);
//Betrag-Textfeld
tfBetrag = new JTextField (40);
tfBetrag.setText ("");
tfBetrag.setBounds (160, 40, 200, 30);
tfBetrag.setBackground(Color.white);
this.getContentPane().add (tfBetrag);
//Kontostand-Textfeld
tfKontostand = new JTextField (40);
tfKontostand.setText ("");
tfKontostand.setBounds (390, 60, 160, 30);
tfKontostand.setBackground(Color.white);
this.getContentPane().add (tfKontostand);
//PIN-Label
JLabel lbPIN = new JLabel ("PIN:");
lbPIN.setBounds (130, 80, 90, 30);
this.getContentPane().add (lbPIN);
//PIN-Textfeld
tfPIN = new JTextField (40);
tfPIN.setText ("");
tfPIN.setBounds (160, 80, 200, 30);
tfPIN.setBackground(Color.white);
this.getContentPane().add (tfPIN);
//System-Textarea
tfSystem = new JTextArea();
tfSystem.setText ("");
tfSystem.setBounds (375, 120, 200, 200);
tfSystem.setBackground(Color.white);
tfSystem.setWrapStyleWord(true);
tfSystem.setLineWrap(true);
this.getContentPane().add (tfSystem);
this.setVisible(true);
}
//Actionlistener
public int pinhilfe()
{
int hilfe = Integer.parseInt(tfPIN.getText());
return hilfe;
}
public String betraghilfe()
{
String hilfe1 = tfBetrag.getText();
return hilfe1;
}
public void setBetrag(String x)
{
tfBetrag.setText("");
}
public void EinzahlungErfolgreich()
{
tfSystem.setText("\n" + "Einzahlung erfolgreich. Kontostand aktualisiert.");
}
public void setKontostand(String y)
{
tfKontostand.setText(y);
}
public void setError()
{
tfSystem.setText("\n" + "Bitte überprüfen sie ihre Eingaben");
}
public void setCatch()
{
tfSystem.setText("\n" + "Betrag muss numerisch sein. Versuchen sie es bitte erneut.");
}
public void setLimit()
{
tfSystem.setText("\n" + "Betrag überschreitet Limit. Bitte kleineren Betrag wählen");
}
public void Dispo()
{
tfSystem.setText("\n" + "Dispo wird mit dieser Auszahlung überzogen. Bitte kleineren Betrag wählen.");
}
public void Auszahlung()
{
tfSystem.setText("\n" + "Auszahlung erfolgreich. Kontostand aktualisiert.");
}
public void Überzogen()
{
tfSystem.setText("\n" + "Dispo überzogen. Bitte Konto ausgleichen.");
}
public void Limit()
{
tfSystem.setText("\n" + "Limit für den heutigen Tag erreicht. Bitte kommen sie morgen wieder.");
}
public boolean istLeer()
{
String pinhilfe = tfPIN.getText();
if(pinhilfe.isEmpty())
{
return true;
}
return false;
}
public void PINfalsch()
{
tfSystem.setText("\n" + "PIN falsch. Bitte korrigieren.");
}
public String getPin()
{
String hilfe3 = tfPIN.getText();
return hilfe3;
}
public void Erfolgreich()
{
tfSystem.setText("\n" + "PIN Authentifizierung erfolgreich");
}
public void actionPerformed(ActionEvent event)
{
String cmd = event.getActionCommand();
//Actions für den Einzahlen Button
if (cmd.equals("Einzahlen"))
{
Test.Einzahlen();
}
else if (cmd.equals("Abheben"))
{
Test.Abheben();
}
else if (cmd.equals("Bestätigen"))
{
Test.Bestätigen();
}
}
public static void main(String[] args)
{
GUI wnd = new GUI();
wnd.setSize(600,400);
wnd.setVisible(true);
}
}