Fix: fixed existing errors with frames

gui
Caner 2022-12-05 13:46:05 +01:00
parent 0405327506
commit e54748d16f
12 changed files with 202 additions and 102 deletions

View File

@ -28,7 +28,7 @@ public class AktienAnzeigenFrame implements ActionListener {
this.frame = new JFrame();
frame.setTitle(bs.getBankname() + " - Aktien anzeigen");
frame.setSize(500, 500);
frame.setSize(400, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
@ -36,17 +36,17 @@ public class AktienAnzeigenFrame implements ActionListener {
panel.setLayout(null);
this.button = new JButton("Aktien anzeigen");
button.setBounds(10, 10, 100, 25);
button.setBounds(10, 10, 130, 25);
button.addActionListener(this);
panel.add(button);
this.button2 = new JButton("Zurück");
button2.setBounds(10, 40, 100, 25);
button2.setBounds(245, 10, 130, 25);
button2.addActionListener(this);
panel.add(button2);
this.output = new JTextArea();
output.setBounds(10, 40, 470, 400);
output.setBounds(10, 55, 365, 200);
output.setEditable(false);
panel.add(output);

View File

@ -1,6 +1,5 @@
package de.hs_mannheim.informatik.bank.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -11,6 +10,7 @@ import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import de.hs_mannheim.informatik.bank.domain.Kontoart;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class AktienKaufenFrame implements ActionListener {
@ -23,6 +23,8 @@ public class AktienKaufenFrame implements ActionListener{
private JLabel label4;
private JLabel label5;
private JLabel label6;
private JLabel label7;
private JLabel label8;
private JTextField input;
private JTextField input2;
private JTextField input3;
@ -30,6 +32,9 @@ public class AktienKaufenFrame implements ActionListener{
private JButton button;
private JButton button2;
private String aktienName1 = "DBK.DE";
private String aktienName2 = "DCO.DE";
private Banksystem bs;
public AktienKaufenFrame(Banksystem bs) {
@ -55,46 +60,54 @@ public class AktienKaufenFrame implements ActionListener{
label2.setBounds(10, 30, 200, 25);
panel.add(label2);
this.label7 = new JLabel("Preis d. Aktie:" + " " + bs.getAktienPreis(aktienName1) + "€");
label7.setBounds(200, 30, 200, 25);
panel.add(label7);
this.label3 = new JLabel("2. Deere & Company (DCO.DE)");
label3.setBounds(10, 50, 200, 25);
panel.add(label3);
this.label8 = new JLabel("Preis d. Aktie:" + " " + bs.getAktienPreis(aktienName2) + "€");
label8.setBounds(200, 50, 200, 25);
panel.add(label8);
this.label4 = new JLabel("Name d. Aktie");
label4.setBounds(10, 80, 200, 25);
label4.setBounds(10, 85, 200, 25);
panel.add(label4);
this.input = new JTextField(20);
input.setBounds(120, 80, 80, 20);
input.setBounds(120, 85, 80, 25);
panel.add(input);
this.label5 = new JLabel("Anzahl");
label5.setBounds(10, 110, 200, 25);
label5.setBounds(10, 115, 200, 25);
panel.add(label5);
this.input2 = new JTextField(20);
input2.setBounds(120, 110, 80, 20);
input2.setBounds(120, 115, 80, 25);
panel.add(input2);
this.label6 = new JLabel("Kontonummer");
label6.setBounds(10, 140, 200, 25);
label6.setBounds(10, 145, 200, 25);
panel.add(label6);
this.input3 = new JTextField(20);
input3.setBounds(120, 140, 80, 20);
input3.setBounds(120, 145, 80, 25);
panel.add(input3);
this.button = new JButton("Kaufen");
button.setBounds(100, 200, 80, 25);
button.setBounds(250, 115, 80, 25);
button.addActionListener(this);
panel.add(button);
this.button2 = new JButton("Zurück");
button2.setBounds(10, 200, 80, 25);
button2.setBounds(200, 415, 80, 25);
button2.addActionListener(this);
panel.add(button2);
this.output = new JTextArea();
output.setBounds(10, 250, 400, 200);
output.setBounds(40, 200, 400, 200);
panel.add(output);
frame.setVisible(true);
@ -108,7 +121,6 @@ public class AktienKaufenFrame implements ActionListener{
if (e.getSource() == button) {
output.append("Preise 1: " + bs.getAktienPreis("DBK.DE") + ", 2: " + bs.getAktienPreis("DCO.DE"));
String aktienName = input.getText();
int anzahl = Integer.parseInt(input2.getText());
@ -130,8 +142,6 @@ public class AktienKaufenFrame implements ActionListener{
FehlerFrame ff = new FehlerFrame(bs);
}
}
}

View File

@ -41,37 +41,37 @@ public class AuswahlmenüDepotFrame implements ActionListener{
panel.setLayout(null);
this.button = new JButton("Geld einzahlen");
button.setBounds(40, 50, 300, 25);
button.setBounds(40, 20, 300, 25);
button.addActionListener(this);
panel.add(button);
this.button2 = new JButton("Geld abheben");
button2.setBounds(40, 80, 300, 25);
button2.setBounds(40, 50, 300, 25);
button2.addActionListener(this);
panel.add(button2);
this.button3 = new JButton("Kontoauszug");
button3.setBounds(40, 110, 300, 25);
button3.setBounds(40, 80, 300, 25);
button3.addActionListener(this);
panel.add(button3);
this.button4 = new JButton("Saldo");
button4.setBounds(40, 140, 300, 25);
button4.setBounds(40, 110, 300, 25);
button4.addActionListener(this);
panel.add(button4);
this.button5 = new JButton("Aktien kaufen");
button5.setBounds(40, 170, 300, 25);
button5.setBounds(40, 140, 300, 25);
button5.addActionListener(this);
panel.add(button5);
this.button6 = new JButton("Aktien anzeigen");
button6.setBounds(40, 200, 300, 25);
button6.setBounds(40, 170, 300, 25);
button6.addActionListener(this);
panel.add(button6);
this.button7 = new JButton("Hauptmenü");
button7.setBounds(40, 230, 300, 25);
this.button7 = new JButton("Auswahlmenü");
button7.setBounds(40, 200, 300, 25);
button7.addActionListener(this);
panel.add(button7);
@ -130,7 +130,7 @@ public class AuswahlmenüDepotFrame implements ActionListener{
else if(e.getSource() == button7) {
frame.dispose();
HauptmenüFrame hauptmenüFrame = new HauptmenüFrame(bs);
AuswahlmenüFrame auswahlmenüFrame = new AuswahlmenüFrame(bs);
}

View File

@ -62,7 +62,7 @@ public class AuswahlmenüGirokontoFrame implements ActionListener {
button5.addActionListener(this);
panel.add(button5);
this.button6 = new JButton("Hauptmenü");
this.button6 = new JButton("Auswahlmenü");
button6.setBounds(40, 200, 300, 25);
button6.addActionListener(this);
panel.add(button6);
@ -101,21 +101,21 @@ public class AuswahlmenüGirokontoFrame implements ActionListener {
else if(e.getSource() == button4) {
frame.dispose();
ÜberweisungsFrame überweisungsFrame = new ÜberweisungsFrame(bs);
SaldoFrame saldoFrame = new SaldoFrame(bs);
}
else if(e.getSource() == button5) {
frame.dispose();
SaldoFrame saldoFrame = new SaldoFrame(bs);
ÜberweisungsFrame überweisungsFrame = new ÜberweisungsFrame(bs);
}
else if(e.getSource() == button6) {
frame.dispose();
HauptmenüFrame hauptmenüFrame = new HauptmenüFrame(bs);
AuswahlmenüFrame auswahlmenüFrame = new AuswahlmenüFrame(bs);
}

View File

@ -57,7 +57,7 @@ public class AuswahlmenüSparkontoFrame implements ActionListener{
button4.addActionListener(this);
panel.add(button4);
this.button5 = new JButton("Hauptmenü");
this.button5 = new JButton("Auswahlmenü");
button5.setBounds(40, 170, 300, 25);
button5.addActionListener(this);
panel.add(button5);
@ -105,7 +105,7 @@ public class AuswahlmenüSparkontoFrame implements ActionListener{
else if(e.getSource() == button5) {
frame.dispose();
HauptmenüFrame hauptmenüFrame = new HauptmenüFrame(bs);
AuswahlmenüFrame auswahlmenüFrame = new AuswahlmenüFrame(bs);
}

View File

@ -11,6 +11,7 @@ import java.awt.event.ActionListener;
import java.io.IOException;
import java.awt.event.ActionEvent;
import de.hs_mannheim.informatik.bank.domain.Kontoart;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class GeldAuszahlenFrame implements ActionListener{
@ -37,51 +38,42 @@ public class GeldAuszahlenFrame implements ActionListener{
this.frame = new JFrame();
frame.setTitle(bs.getBankname() + " - Geld auszahlen");
frame.setSize(500, 400);
frame.setSize(400, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.add(panel);
panel.setLayout(null);
this.button = new JButton("Kontostand");
button.setBounds(10, 10, 120, 25);
button.addActionListener(this);
panel.add(button);
this.output = new JTextArea();
output.setBounds(180, 10, 250, 25);
output.setEditable(false);
panel.add(output);
this.label = new JLabel("Kontonummer");
label.setBounds(10, 50, 100, 25);
label.setBounds(10, 10, 100, 25);
panel.add(label);
this.input = new JTextField();
input.setBounds(180, 50, 250, 25);
input.setBounds(140, 10, 120, 25);
panel.add(input);
this.label2 = new JLabel("Betrag (€)");
label2.setBounds(10, 80, 100, 25);
label2.setBounds(10, 40, 100, 25);
panel.add(label2);
this.input2 = new JTextField();
input2.setBounds(180, 80, 250, 25);
input2.setBounds(140, 40, 120, 25);
panel.add(input2);
this.output2 = new JTextArea();
output2.setBounds(25, 170, 435, 165);
output2.setBounds(70, 120, 250, 100);
output2.setEditable(false);
panel.add(output2);
this.button2 = new JButton("Geld auszahlen");
button2.setBounds(10, 120, 120, 25);
button2.setBounds(140, 85, 120, 25);
button2.addActionListener(this);
panel.add(button2);
this.button3 = new JButton("Auswahlmenü");
button3.setBounds(355, 120, 120, 25);
this.button3 = new JButton("Zurück");
button3.setBounds(140, 230, 120, 25);
button3.addActionListener(this);
panel.add(button3);
@ -128,8 +120,31 @@ public class GeldAuszahlenFrame implements ActionListener{
else if(e.getSource() == button3) {
if(bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Sparkonto) {
frame.dispose();
AuswahlmenüFrame amf = new AuswahlmenüFrame(bs);
AuswahlmenüSparkontoFrame asf = new AuswahlmenüSparkontoFrame(bs);
}
else if(bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Girokonto) {
frame.dispose();
AuswahlmenüGirokontoFrame agf = new AuswahlmenüGirokontoFrame(bs);
}
else if(bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Depot) {
frame.dispose();
AuswahlmenüDepotFrame adf = new AuswahlmenüDepotFrame(bs);
} else {
frame.dispose();
FehlerFrame ff = new FehlerFrame(bs);
}
}

View File

@ -11,6 +11,7 @@ import java.awt.event.ActionListener;
import java.io.IOException;
import java.awt.event.ActionEvent;
import de.hs_mannheim.informatik.bank.domain.Kontoart;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class GeldEinzahlenFrame implements ActionListener {
@ -69,7 +70,7 @@ public class GeldEinzahlenFrame implements ActionListener {
button.setBounds(40, 305, 300, 25);
panel.add(button);
this.button2 = new JButton("Auswahlmenü");
this.button2 = new JButton("Zurück");
button2.addActionListener(this);
button2.setBounds(40, 410, 300, 25);
panel.add(button2);
@ -100,8 +101,31 @@ public class GeldEinzahlenFrame implements ActionListener {
else if (e.getSource() == button2) {
if(bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Sparkonto) {
frame.dispose();
AuswahlmenüFrame amf = new AuswahlmenüFrame(bs);
AuswahlmenüSparkontoFrame asf = new AuswahlmenüSparkontoFrame(bs);
}
else if(bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Girokonto) {
frame.dispose();
AuswahlmenüGirokontoFrame agf = new AuswahlmenüGirokontoFrame(bs);
}
else if(bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Depot) {
frame.dispose();
AuswahlmenüDepotFrame adf = new AuswahlmenüDepotFrame(bs);
} else {
frame.dispose();
FehlerFrame ff = new FehlerFrame(bs);
}
}

View File

@ -16,6 +16,7 @@ public class HauptmenüFrame implements ActionListener {
private JFrame frame;
private JButton button;
private JButton button2;
private JButton button3;
private JLabel label;
private JLabel label2;
@ -29,7 +30,7 @@ public class HauptmenüFrame implements ActionListener {
this.frame = new JFrame();
frame.setTitle(bs.getBankname() + " - Hauptmenü");
frame.setSize(300, 200);
frame.setSize(300, 250);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
@ -45,15 +46,20 @@ public class HauptmenüFrame implements ActionListener {
panel.add(label2);
this.button = new JButton("Neuen Kunden anlegen");
button.setBounds(1, 80, 300, 25);
button.setBounds(15, 80, 250, 25);
button.addActionListener(this);
panel.add(button);
this.button2 = new JButton("Bei bestehendem Kunden einloggen");
button2.setBounds(1, 110, 300, 25);
this.button2 = new JButton("Bei Kunden einloggen");
button2.setBounds(15, 110, 250, 25);
button2.addActionListener(this);
panel.add(button2);
this.button3 = new JButton("Beenden");
button3.setBounds(15, 140, 250, 25);
button3.addActionListener(this);
panel.add(button3);
frame.setVisible(true);
}
@ -77,6 +83,12 @@ public class HauptmenüFrame implements ActionListener {
}
else if (e.getSource() == button3) {
frame.dispose();
}
}
}

View File

@ -74,7 +74,7 @@ public class KontoAuswahlFrame implements ActionListener{
} else if(bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Depot) {
frame.dispose();
// TODO Auswahl Depot
AuswahlmenüDepotFrame auswahlmenüDepotFrame = new AuswahlmenüDepotFrame(bs);
} else {

View File

@ -10,6 +10,7 @@ import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import de.hs_mannheim.informatik.bank.domain.Kontoart;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class KontoauszugFrame implements ActionListener {
@ -24,7 +25,6 @@ public class KontoauszugFrame implements ActionListener{
private Banksystem bs;
public KontoauszugFrame(Banksystem bs) {
this.bs = bs;
@ -49,7 +49,7 @@ public class KontoauszugFrame implements ActionListener{
panel.add(input);
this.output = new JTextArea();
output.setBounds(10, 50, 414, 200);
output.setBounds(10, 50, 414, 150);
output.setEditable(false);
panel.add(output);
@ -59,7 +59,7 @@ public class KontoauszugFrame implements ActionListener{
panel.add(button);
this.button2 = new JButton("Zurück");
button2.setBounds(10, 260, 100, 25);
button2.setBounds(170, 220, 100, 25);
button2.addActionListener(this);
panel.add(button2);
@ -67,7 +67,6 @@ public class KontoauszugFrame implements ActionListener{
}
@Override
public void actionPerformed(ActionEvent e) {
@ -99,8 +98,24 @@ public class KontoauszugFrame implements ActionListener{
else if (e.getSource() == button2) {
if (bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Sparkonto) {
frame.dispose();
AuswahlmenüFrame amf = new AuswahlmenüFrame(bs);
AuswahlmenüSparkontoFrame asf = new AuswahlmenüSparkontoFrame(bs);
}
else if (bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Girokonto) {
frame.dispose();
AuswahlmenüGirokontoFrame agf = new AuswahlmenüGirokontoFrame(bs);
}
else if (bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Depot) {
frame.dispose();
AuswahlmenüDepotFrame adf = new AuswahlmenüDepotFrame(bs);
} else {
@ -112,3 +127,4 @@ public class KontoauszugFrame implements ActionListener{
}
}
}

View File

@ -10,6 +10,7 @@ import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import de.hs_mannheim.informatik.bank.domain.Kontoart;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class SaldoFrame implements ActionListener {
@ -66,7 +67,7 @@ public class SaldoFrame implements ActionListener {
button.addActionListener(this);
panel.add(button);
this.button2 = new JButton("Auswahlmenü");
this.button2 = new JButton("Zurück");
button2.setBounds(265, 40, 160, 25);
button2.addActionListener(this);
panel.add(button2);
@ -91,8 +92,31 @@ public class SaldoFrame implements ActionListener {
} else if (e.getSource() == button2) {
if (bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Sparkonto) {
frame.dispose();
AuswahlmenüSparkontoFrame auswahlmenü = new AuswahlmenüSparkontoFrame(bs);
AuswahlmenüSparkontoFrame asf = new AuswahlmenüSparkontoFrame(bs);
}
else if (bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Girokonto) {
frame.dispose();
AuswahlmenüGirokontoFrame agf = new AuswahlmenüGirokontoFrame(bs);
}
else if (bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Depot) {
frame.dispose();
AuswahlmenüDepotFrame adf = new AuswahlmenüDepotFrame(bs);
} else {
frame.dispose();
FehlerFrame ff = new FehlerFrame(bs);
}
}

View File

@ -10,9 +10,9 @@ import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import de.hs_mannheim.informatik.bank.domain.Kontoart;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class ÜberweisungsFrame implements ActionListener {
private JPanel panel;
@ -97,8 +97,6 @@ public class ÜberweisungsFrame implements ActionListener{
}
@Override
public void actionPerformed(ActionEvent e) {
@ -113,7 +111,8 @@ public class ÜberweisungsFrame implements ActionListener{
double betrag = Double.parseDouble(input3.getText());
String verwendungszweck = input4.getText();
boolean erfolg = bs.überweisungBeauftragen(startkonto, zielkonto, (long) (betrag * 100), verwendungszweck);
boolean erfolg = bs.überweisungBeauftragen(startkonto, zielkonto, (long) (betrag * 100),
verwendungszweck);
output.append("Überweisung" + ((!erfolg) ? " nicht" : "") + " erfolgreich ausgeführt.");
@ -131,7 +130,7 @@ public class ÜberweisungsFrame implements ActionListener{
else if (e.getSource() == button2) {
frame.dispose();
AuswahlmenüGirokontoFrame amgf = new AuswahlmenüGirokontoFrame(bs);
AuswahlmenüGirokontoFrame amgk = new AuswahlmenüGirokontoFrame(bs);
} else {