From d09bf5386f71e48327295f0682f9dadafc335619 Mon Sep 17 00:00:00 2001 From: Caner Date: Fri, 2 Dec 2022 14:33:14 +0100 Subject: [PATCH] Fix: added & improved gui's / code refactoring --- .../de/hs_mannheim/informatik/bank/Main.java | 7 +- .../informatik/bank/gui/AuswahlmenüFrame.java | 38 +++-- .../bank/gui/GeldAuszahlenFrame.java | 138 ++++++++++++++++++ .../bank/gui/GeldEinzahlenFrame.java | 33 ++--- .../informatik/bank/gui/HauptmenüFrame.java | 27 ++-- .../bank/gui/KontoAnlegenFrame.java | 138 +++++++++--------- .../bank/gui/KontoListingFrame.java | 67 +++++---- .../informatik/bank/gui/KundeAnlegen.java | 32 +--- .../informatik/bank/gui/LoginFehlerFrame.java | 11 +- .../informatik/bank/gui/LoginFrame.java | 39 +++-- 10 files changed, 325 insertions(+), 205 deletions(-) create mode 100644 Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/GeldAuszahlenFrame.java diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/Main.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/Main.java index a0ed294..413d0c2 100644 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/Main.java +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/Main.java @@ -1,21 +1,16 @@ package de.hs_mannheim.informatik.bank; import de.hs_mannheim.informatik.bank.facade.Banksystem; -import de.hs_mannheim.informatik.bank.gui.AuswahlmenüFrame; -import de.hs_mannheim.informatik.bank.gui.GeldEinzahlenFrame; import de.hs_mannheim.informatik.bank.gui.HauptmenüFrame; - public class Main { public static void main(String[] args) throws Exception { - + Banksystem bs = new Banksystem("Spaßkasse Mannheim"); HauptmenüFrame hmf = new HauptmenüFrame(bs); - //GeldEinzahlenFrame gef = new GeldEinzahlenFrame(bs); - } } \ No newline at end of file diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/AuswahlmenüFrame.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/AuswahlmenüFrame.java index 87976a1..83a18b2 100644 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/AuswahlmenüFrame.java +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/AuswahlmenüFrame.java @@ -9,7 +9,7 @@ import java.awt.event.ActionEvent; import de.hs_mannheim.informatik.bank.facade.Banksystem; -public class AuswahlmenüFrame implements ActionListener{ +public class AuswahlmenüFrame implements ActionListener { private JPanel panel; private JFrame frame; @@ -17,10 +17,11 @@ public class AuswahlmenüFrame implements ActionListener{ private JButton button2; private JButton button3; private JButton button4; + private JButton button5; private Banksystem bs; - public AuswahlmenüFrame(Banksystem bs){ + public AuswahlmenüFrame(Banksystem bs) { this.bs = bs; @@ -50,11 +51,16 @@ public class AuswahlmenüFrame implements ActionListener{ button3.addActionListener(this); panel.add(button3); - this.button4 = new JButton("Hauptmenü"); + this.button4 = new JButton("Geld abheben"); button4.setBounds(40, 140, 300, 25); button4.addActionListener(this); panel.add(button4); + this.button5 = new JButton("Hauptmenü"); + button5.setBounds(40, 170, 300, 25); + button5.addActionListener(this); + panel.add(button5); + frame.setVisible(true); } @@ -63,32 +69,36 @@ public class AuswahlmenüFrame implements ActionListener{ public void actionPerformed(ActionEvent e) { System.out.println("Auswahlmenü..."); - - if(e.getSource() == button) { + if (e.getSource() == button) { this.frame.dispose(); KontoAnlegenFrame kontoAnlegenFrame = new KontoAnlegenFrame(bs); - - } - else if(e.getSource() == button2) { + + } else if (e.getSource() == button2) { this.frame.dispose(); KontoListingFrame kontoListingFrame = new KontoListingFrame(bs); - - } - else if(e.getSource() == button3) { + + } else if (e.getSource() == button3) { this.frame.dispose(); GeldEinzahlenFrame geldEinzahlenFrame = new GeldEinzahlenFrame(bs); - + } - else if(e.getSource() == button4) { + else if (e.getSource() == button4) { + + this.frame.dispose(); + GeldAuszahlenFrame geldAuszahlenFrame = new GeldAuszahlenFrame(bs); + + } + + else if (e.getSource() == button5) { this.frame.dispose(); HauptmenüFrame hauptmenüFrame = new HauptmenüFrame(bs); - + } } diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/GeldAuszahlenFrame.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/GeldAuszahlenFrame.java new file mode 100644 index 0000000..7655ca9 --- /dev/null +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/GeldAuszahlenFrame.java @@ -0,0 +1,138 @@ +package de.hs_mannheim.informatik.bank.gui; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +import java.awt.event.ActionListener; +import java.io.IOException; +import java.awt.event.ActionEvent; + +import de.hs_mannheim.informatik.bank.facade.Banksystem; + +public class GeldAuszahlenFrame implements ActionListener{ + + private JPanel panel; + private JFrame frame; + private JButton button; + private JButton button2; + private JButton button3; + private JTextArea output; + private JTextArea output2; + private JTextField input; + private JTextField input2; + private JLabel label; + private JLabel label2; + + private Banksystem bs; + + public GeldAuszahlenFrame(Banksystem bs){ + + this.bs = bs; + + this.panel = new JPanel(); + + this.frame = new JFrame(); + frame.setTitle(bs.getBankname() + " - Geld auszahlen"); + frame.setSize(500, 400); + 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); + panel.add(label); + + this.input = new JTextField(); + input.setBounds(180, 50, 250, 25); + panel.add(input); + + this.label2 = new JLabel("Betrag (€)"); + label2.setBounds(10, 80, 100, 25); + panel.add(label2); + + this.input2 = new JTextField(); + input2.setBounds(180, 80, 250, 25); + panel.add(input2); + + this.output2 = new JTextArea(); + output2.setBounds(25, 170, 435, 165); + output2.setEditable(false); + panel.add(output2); + + this.button2 = new JButton("Geld auszahlen"); + button2.setBounds(10, 120, 120, 25); + button2.addActionListener(this); + panel.add(button2); + + this.button3 = new JButton("Auswahlmenü"); + button3.setBounds(355, 120, 120, 25); + button3.addActionListener(this); + panel.add(button3); + + + frame.setVisible(true); + + } + + @Override + public void actionPerformed(ActionEvent e) { + + System.out.println("Geld auszahlen..."); + + if(e.getSource() == button){ + + long kontostand = bs.getKontostand(Integer.parseInt(input.getText())) / 100; + + output.append("Kontostand beträgt " + kontostand + "€"); + + input.setText(""); + + + } + + else if(e.getSource() == button2) { + + try { + + boolean erfolg = bs.geldAuszahlen(Integer.parseInt(input.getText()), (long) Double.parseDouble(input2.getText()) * 100); + long neuerKontostand = bs.getKontostand(Integer.parseInt(input.getText())); + + output2.append("Auszahlung" + ((!erfolg)? " nicht" : "" ) + " erfolgreich.\tneuer Kontostand: " + neuerKontostand / 100 + "€"); + + input.setText(""); + input2.setText(""); + + } catch (NumberFormatException e1) { + e1.printStackTrace(); + } catch (IOException e1) { + e1.printStackTrace(); + } + + } + + else if(e.getSource() == button3) { + + frame.dispose(); + AuswahlmenüFrame amf = new AuswahlmenüFrame(bs); + + } + + } + +} diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/GeldEinzahlenFrame.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/GeldEinzahlenFrame.java index d407cd5..934ddfe 100644 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/GeldEinzahlenFrame.java +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/GeldEinzahlenFrame.java @@ -28,7 +28,7 @@ public class GeldEinzahlenFrame implements ActionListener { private Banksystem bs; - public GeldEinzahlenFrame(Banksystem bs){ + public GeldEinzahlenFrame(Banksystem bs) { this.bs = bs; @@ -51,7 +51,7 @@ public class GeldEinzahlenFrame implements ActionListener { input.setBounds(140, 20, 165, 25); panel.add(input); - this.label2 = new JLabel("Betrag"); + this.label2 = new JLabel("Betrag (€)"); label2.setBounds(10, 50, 80, 25); panel.add(label2); @@ -71,34 +71,26 @@ public class GeldEinzahlenFrame implements ActionListener { this.button2 = new JButton("Auswahlmenü"); button2.addActionListener(this); - button2.setBounds(40, 380, 300, 25); + button2.setBounds(40, 410, 300, 25); panel.add(button2); - this.button3 = new JButton("Haupmenü"); - button3.addActionListener(this); - button3.setBounds(40, 410, 300, 25); - panel.add(button3); - frame.setVisible(true); } - @Override public void actionPerformed(ActionEvent e) { System.out.println("Geld einzahlen..."); - int kontonummer = Integer.parseInt(input.getText()); - Double betrag = Double.parseDouble(input2.getText()); - - if (e.getSource() == button) { - + try { - bs.geldEinzahlen(kontonummer, (long) (betrag * 100)); - output.append("Einzahlung von " + input2.getText() + " erfolgreich\nNeuer Kontostand beträgt " + (bs.getKontostand(Integer.parseInt(input.getText())) / 100) + " €\n"); + bs.geldEinzahlen(Integer.parseInt(input.getText()), + (long) (Double.parseDouble(input2.getText()) * 100)); + output.append("Einzahlung von " + input2.getText() + " erfolgreich\nNeuer Kontostand beträgt " + + (bs.getKontostand(Integer.parseInt(input.getText())) / 100) + " €\n"); } catch (IOException e1) { e1.printStackTrace(); @@ -113,13 +105,6 @@ public class GeldEinzahlenFrame implements ActionListener { } - else if (e.getSource() == button3) { - - frame.dispose(); - HauptmenüFrame hmf = new HauptmenüFrame(bs); - - } - } - + } diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/HauptmenüFrame.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/HauptmenüFrame.java index e34bdb0..b97c0cb 100644 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/HauptmenüFrame.java +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/HauptmenüFrame.java @@ -10,7 +10,7 @@ import java.awt.event.ActionEvent; import de.hs_mannheim.informatik.bank.facade.Banksystem; -public class HauptmenüFrame implements ActionListener{ +public class HauptmenüFrame implements ActionListener { private JPanel panel; private JFrame frame; @@ -18,11 +18,10 @@ public class HauptmenüFrame implements ActionListener{ private JButton button2; private JLabel label; private JLabel label2; - private Banksystem bs; - public HauptmenüFrame(Banksystem bs){ + public HauptmenüFrame(Banksystem bs) { this.bs = bs; @@ -37,7 +36,6 @@ public class HauptmenüFrame implements ActionListener{ frame.add(panel); panel.setLayout(null); - this.label = new JLabel(bs.getBankname()); label.setBounds(10, 10, 200, 25); panel.add(label); @@ -62,26 +60,23 @@ public class HauptmenüFrame implements ActionListener{ @Override public void actionPerformed(ActionEvent e) { - + System.out.println("Hauptmenü..."); - - - - if(e.getSource() == button) { + if (e.getSource() == button) { frame.dispose(); KundeAnlegen kundeAnlegen = new KundeAnlegen(bs); - + } - else if(e.getSource() == button2) { - - frame.dispose(); - LoginFrame loginFrame = new LoginFrame(bs); - + else if (e.getSource() == button2) { + + frame.dispose(); + LoginFrame loginFrame = new LoginFrame(bs); + } } - + } diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KontoAnlegenFrame.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KontoAnlegenFrame.java index eb3b723..df90dfc 100644 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KontoAnlegenFrame.java +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KontoAnlegenFrame.java @@ -8,96 +8,98 @@ import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; - import de.hs_mannheim.informatik.bank.domain.Kontoart; import de.hs_mannheim.informatik.bank.facade.Banksystem; -public class KontoAnlegenFrame extends JFrame implements ActionListener { +public class KontoAnlegenFrame implements ActionListener { - private JPanel panel; - private JFrame frame; - private JButton button; - private JButton button2; - private JButton button3; - private JTextArea output; - - + private JPanel panel; + private JFrame frame; + private JButton button; + private JButton button2; + private JButton button3; + private JButton button4; + private JTextArea output; - private Banksystem bs; + private Banksystem bs; - public KontoAnlegenFrame(Banksystem bs) { + public KontoAnlegenFrame(Banksystem bs) { - this.bs = bs; + this.bs = bs; - this.panel = new JPanel(); + this.panel = new JPanel(); - this.frame = new JFrame(); - this.frame.setTitle(bs.getBankname() + " - Konto anlegen"); - this.frame.setSize(400, 400); - this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.frame.add(panel); + this.frame = new JFrame(); + frame.setTitle(bs.getBankname() + " - Konto anlegen"); + frame.setSize(400, 400); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLocationRelativeTo(null); + frame.setResizable(false); + frame.add(panel); + panel.setLayout(null); - this.button = new JButton("Girokonto"); - this.button.setBounds(10, 80, 80, 25); - this.button.addActionListener(this); - this.panel.add(button); + this.button = new JButton("Girokonto"); + button.setBounds(10, 10, 95, 25); + button.addActionListener(this); + panel.add(button); - this.button2 = new JButton("Sparkonto"); - this.button2.setBounds(100, 80, 80, 25); - this.button2.addActionListener(this); - this.panel.add(button2); + this.button2 = new JButton("Sparkonto"); + button2.setBounds(145, 10, 95, 25); + button2.addActionListener(this); + panel.add(button2); - this.button3 = new JButton("Depot"); - this.button3.setBounds(190, 80, 80, 25); - this.button3.addActionListener(this); - this.panel.add(button3); + this.button3 = new JButton("Depot"); + button3.setBounds(280, 10, 95, 25); + button3.addActionListener(this); + panel.add(button3); - this.output = new JTextArea(20, 20); - this.output.setBounds(10, 110, 300, 200); - this.output.setEditable(false); - this.panel.add(output); + this.button4 = new JButton("Auswahlmenü"); + button4.setBounds(10, 320, 120, 25); + button4.addActionListener(this); + panel.add(button4); - this.frame.setVisible(true); + this.output = new JTextArea(); + output.setBounds(10, 50, 365, 250); + output.setEditable(false); + panel.add(output); - } + frame.setVisible(true); - @Override - public void actionPerformed(ActionEvent e) { - - System.out.println("Konto anlegen..."); - boolean running = true; + } - while(running) { + @Override + public void actionPerformed(ActionEvent e) { - try { + System.out.println("Konto anlegen..."); - if(e.getSource() == button) { - bs.kontoAnlegen(bs.getCurrentKunde(), Kontoart.Girokonto); - this.output.append("Girokonto wurde angelegt\n"); - running = false; - } else if(e.getSource() == button2) { - bs.kontoAnlegen(bs.getCurrentKunde(), Kontoart.Sparkonto); - this.output.append("Sparkonto wurde angelegt\n"); - running = false; - } else if(e.getSource() == button3) { - bs.kontoAnlegen(bs.getCurrentKunde(), Kontoart.Depot); - this.output.append("Depot wurde angelegt\n"); - running = false; - } - - } - - catch (Exception ex) { - ex.printStackTrace(); - } + try { - running = false; + if (e.getSource() == button) { - } - + int kontonummer = bs.kontoAnlegen(bs.getCurrentKunde(), Kontoart.Girokonto); + output.append("Girokonto mit der Kontonummer " + kontonummer + " wurde angelegt\n"); + } else if (e.getSource() == button2) { - } + int kontonummer = bs.kontoAnlegen(bs.getCurrentKunde(), Kontoart.Sparkonto); + output.append("Sparkonto mit der Kontonummer " + kontonummer + " wurde angelegt\n"); - + } else if (e.getSource() == button3) { + + int kontonummer = bs.kontoAnlegen(bs.getCurrentKunde(), Kontoart.Depot); + output.append("Depot mit der Kontonummer " + kontonummer + " wurde angelegt\n"); + + } else if (e.getSource() == button4) { + + frame.dispose(); + AuswahlmenüFrame amf = new AuswahlmenüFrame(bs); + + } + } + + catch (Exception ex) { + ex.printStackTrace(); + } + + } } diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KontoListingFrame.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KontoListingFrame.java index 23869f9..1e07b20 100644 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KontoListingFrame.java +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KontoListingFrame.java @@ -8,55 +8,72 @@ import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; - import de.hs_mannheim.informatik.bank.facade.Banksystem; -public class KontoListingFrame extends JFrame implements ActionListener{ +public class KontoListingFrame implements ActionListener { - private JPanel panel; + private JPanel panel; private JFrame frame; private JButton button; + private JButton button2; private JTextArea output; - private Banksystem bs; public KontoListingFrame(Banksystem bs) { - + this.bs = bs; this.panel = new JPanel(); - + this.frame = new JFrame(); - this.frame.setTitle(bs.getBankname() + " - Kontoliste"); - this.frame.setSize(400, 400); - this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.frame.add(panel); + frame.setTitle(bs.getBankname() + " - Kontoliste"); + frame.setSize(500, 400); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLocationRelativeTo(null); + frame.setResizable(false); + frame.add(panel); + panel.setLayout(null); this.button = new JButton("Kontoliste abrufen"); - this.button.setBounds(10, 80, 160, 25); - this.button.addActionListener(this); - this.panel.add(button); + button.setBounds(10, 10, 160, 25); + button.addActionListener(this); + panel.add(button); - this.output = new JTextArea(20, 20); - this.output.setBounds(10, 110, 300, 200); - this.output.setEditable(false); - this.panel.add(output); + this.button2 = new JButton("Auswahlmenü"); + button2.setBounds(215, 10, 260, 25); + button2.addActionListener(this); + panel.add(button2); - - this.frame.setVisible(true); - - } + this.output = new JTextArea(); + output.setBounds(10, 60, 465, 280); + output.setEditable(false); + panel.add(output); - @Override + frame.setVisible(true); + + } + + @Override public void actionPerformed(ActionEvent e) { + System.out.println("Kontenliste abrufen..."); - String[] konten = bs.getKontenlisteForKunde(); + if (e.getSource() == button) { + + String[] konten = bs.getKontenlisteForKunde(); + + for (String konto : konten) { + output.append(konto + "\n"); + } + + } else if (e.getSource() == button2) { + + frame.dispose(); + AuswahlmenüFrame auswahlmenü = new AuswahlmenüFrame(bs); - for(String konto : konten){ - this.output.append(konto + "\n"); } } + } diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KundeAnlegen.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KundeAnlegen.java index 514a092..a4ffd4e 100644 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KundeAnlegen.java +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KundeAnlegen.java @@ -12,9 +12,7 @@ import java.awt.event.ActionEvent; import de.hs_mannheim.informatik.bank.facade.Banksystem; - - -public class KundeAnlegen extends JFrame implements ActionListener{ +public class KundeAnlegen extends JFrame implements ActionListener { private JPanel panel; private JLabel label; @@ -27,11 +25,8 @@ public class KundeAnlegen extends JFrame implements ActionListener{ private JButton button; private JButton button2; private JTextArea output; - - private Banksystem bs; - public KundeAnlegen(Banksystem bs) { @@ -39,7 +34,6 @@ public class KundeAnlegen extends JFrame implements ActionListener{ this.panel = new JPanel(); - this.frame = new JFrame(); frame.setTitle(bs.getBankname() + " - Kunde anlegen"); frame.setSize(400, 500); @@ -88,32 +82,26 @@ public class KundeAnlegen extends JFrame implements ActionListener{ output.setEditable(false); panel.add(output); - frame.setVisible(true); - - } + } @Override public void actionPerformed(ActionEvent e) { System.out.println("Kunde anlegen..."); - - String name = input.getText(); - String surname = input2.getText(); - int age = Integer.parseInt(input3.getText()); if (e.getSource() == button) { try { - - bs.addNewKunde(name, surname, age); - output.append("Ihr Kundenkonto mit der ID [" + bs.getKundenID() + "] wurde erfolgreich angelegt.\n"); + bs.addNewKunde(input.getText(), input2.getText(), Integer.parseInt(input3.getText())); - input.setText(""); - input2.setText(""); - input3.setText(""); + output.append("Ihr Kundenkonto mit der ID [" + bs.getKundenID() + "] wurde erfolgreich angelegt.\n"); + + input.setText(""); + input2.setText(""); + input3.setText(""); } catch (Exception ex) { ex.printStackTrace(); @@ -126,10 +114,6 @@ public class KundeAnlegen extends JFrame implements ActionListener{ } - } } - - - diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/LoginFehlerFrame.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/LoginFehlerFrame.java index 6d0c640..8bf60dc 100644 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/LoginFehlerFrame.java +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/LoginFehlerFrame.java @@ -10,7 +10,7 @@ import java.awt.event.ActionListener; import de.hs_mannheim.informatik.bank.facade.Banksystem; -public class LoginFehlerFrame implements ActionListener{ +public class LoginFehlerFrame implements ActionListener { private JPanel panel; private JFrame frame; @@ -19,7 +19,6 @@ public class LoginFehlerFrame implements ActionListener{ private Banksystem bs; - public LoginFehlerFrame(Banksystem bs) { this.bs = bs; @@ -45,22 +44,20 @@ public class LoginFehlerFrame implements ActionListener{ button.addActionListener(this); panel.add(button); - frame.setVisible(true); } - @Override public void actionPerformed(ActionEvent e) { - + System.out.println("Loginfehler..."); - if(e.getSource() == button) { + if (e.getSource() == button) { frame.dispose(); LoginFrame lf = new LoginFrame(bs); } } - + } diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/LoginFrame.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/LoginFrame.java index cbf8c57..67f8172 100644 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/LoginFrame.java +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/LoginFrame.java @@ -11,7 +11,7 @@ import java.awt.event.ActionEvent; import de.hs_mannheim.informatik.bank.facade.Banksystem; -public class LoginFrame implements ActionListener{ +public class LoginFrame implements ActionListener { private JPanel panel; private JFrame frame; @@ -21,7 +21,7 @@ public class LoginFrame implements ActionListener{ private Banksystem bs; - public LoginFrame(Banksystem bs){ + public LoginFrame(Banksystem bs) { this.bs = bs; @@ -51,38 +51,35 @@ public class LoginFrame implements ActionListener{ frame.setVisible(true); - } @Override public void actionPerformed(ActionEvent e) { - + System.out.println("Login..."); - + int kundenID = Integer.parseInt(input.getText()); - try { + try { - bs.setCurrentKunde(bs.getKunde(kundenID)); + bs.setCurrentKunde(bs.getKunde(kundenID)); - if(bs.getCurrentKunde() != null){ + if (bs.getCurrentKunde() != null) { - frame.dispose(); - AuswahlmenüFrame auswahlmenü = new AuswahlmenüFrame(bs); - - } else { + frame.dispose(); + AuswahlmenüFrame auswahlmenü = new AuswahlmenüFrame(bs); - frame.dispose(); - LoginFehlerFrame lff = new LoginFehlerFrame(bs); - - } - - } catch (Exception ex) { - ex.printStackTrace(); + } else { + + frame.dispose(); + LoginFehlerFrame lff = new LoginFehlerFrame(bs); + + } + + } catch (Exception ex) { + ex.printStackTrace(); } } } - -