From c0967d7fa21a6b9240e9bb8898f264b8d6e8f793 Mon Sep 17 00:00:00 2001 From: Caner Date: Wed, 30 Nov 2022 14:41:17 +0100 Subject: [PATCH] New: KundeAnlegen panel --- .../de/hs_mannheim/informatik/bank/Main.java | 9 +- .../informatik/bank/gui/KundeAnlegen.java | 110 ++++++++++++++++++ .../bank/gui/KundeAnlegenFrame.java | 71 ----------- 3 files changed, 115 insertions(+), 75 deletions(-) create mode 100644 Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KundeAnlegen.java delete mode 100644 Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KundeAnlegenFrame.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 309f7da..cbb8f5c 100644 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/Main.java +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/Main.java @@ -1,7 +1,8 @@ package de.hs_mannheim.informatik.bank; import de.hs_mannheim.informatik.bank.facade.Banksystem; -import de.hs_mannheim.informatik.bank.gui.KundeAnlegenFrame; + +import de.hs_mannheim.informatik.bank.gui.KundeAnlegen; public class Main { @@ -9,9 +10,9 @@ public class Main { public static void main(String[] args) throws Exception { Banksystem bs = new Banksystem("Spaßkasse Mannheim"); - - KundeAnlegenFrame kaf = new KundeAnlegenFrame(bs); - kaf.setVisible(true); + + KundeAnlegen tp = new KundeAnlegen(bs); + } 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 new file mode 100644 index 0000000..afd0735 --- /dev/null +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KundeAnlegen.java @@ -0,0 +1,110 @@ +package de.hs_mannheim.informatik.bank.gui; + +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +import de.hs_mannheim.informatik.bank.facade.Banksystem; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; + +public class KundeAnlegen extends JFrame implements ActionListener{ + + private JPanel panel; + private JLabel label; + private JLabel label2; + private JLabel label3; + private JTextField input; + private JTextField input2; + private JTextField input3; + private JFrame frame; + private JButton button; + private JTextArea output; + + + private Banksystem bs; + + + public KundeAnlegen(Banksystem bs) { + + this.bs = bs; + + this.panel = new JPanel(); + + + this.frame = new JFrame(); + this.frame.setTitle(bs.getBankname()); + this.frame.setSize(400, 400); + this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.frame.add(panel); + this.panel.setLayout(null); + + this.label = new JLabel("Name"); + label.setBounds(10, 20, 80, 25); + this.panel.add(label); + + this.input = new JTextField(20); + this.input.setBounds(100, 20, 165, 25); + this.panel.add(input); + + this.label2 = new JLabel("Nachname"); + label2.setBounds(10, 50, 80, 25); + this.panel.add(label2); + + this.input2 = new JTextField(20); + this.input2.setBounds(100, 50, 165, 25); + this.panel.add(input2); + + this.label3 = new JLabel("Alter"); + label3.setBounds(10, 80, 80, 25); + this.panel.add(label3); + + this.input3 = new JTextField(20); + this.input3.setBounds(100, 80, 165, 25); + this.panel.add(input3); + + this.output = new JTextArea(10, 20); + this.output.setBounds(10, 110, 300, 200); + this.output.setLineWrap(true); + this.output.setWrapStyleWord(true); + this.output.setEditable(false); + this.panel.add(output); + + this.button = new JButton("Kunde anlegen"); + button.addActionListener(this); + button.setBounds(10, 320, 300, 25); + this.panel.add(button); + + this.frame.setVisible(true); + + } + + + @Override + public void actionPerformed(ActionEvent e) { + + System.out.println("Kunde anlegen..."); + + try { + + bs.setCurrentKunde(bs.addNewKunde(input.getText(), input2.getText(), + Integer.parseInt(input3.getText()))); + + this.output.append("Ihr Kundenkonto mit der ID [" + bs.getKundenID() + "] wurde erfolgreich angelegt.\n"); + + } catch (Exception e1) { + e1.printStackTrace(); + } + + } + + + + + +} diff --git a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KundeAnlegenFrame.java b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KundeAnlegenFrame.java deleted file mode 100644 index 90fb606..0000000 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/gui/KundeAnlegenFrame.java +++ /dev/null @@ -1,71 +0,0 @@ -package de.hs_mannheim.informatik.bank.gui; - -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; - -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; - -import de.hs_mannheim.informatik.bank.facade.Banksystem; - -public class KundeAnlegenFrame extends JFrame implements ActionListener { - - private JTextField eingabeName; - private JTextField eingabeSurname; - private JTextField eingabeAge; - private JTextArea ausgabe; - private JButton ok; - - private Banksystem bs; - - public KundeAnlegenFrame(Banksystem bs) { - - this.bs = bs; - - this.setTitle(bs.getBankname()); - this.setSize(400, 300); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - eingabeName = new JTextField(20); - eingabeSurname = new JTextField(15); - eingabeAge = new JTextField(10); - - ausgabe = new JTextArea(10, 20); - ausgabe.setLineWrap(true); - ausgabe.setWrapStyleWord(true); - - JScrollPane sp = new JScrollPane(ausgabe); - - ok = new JButton("Kunde anlegen"); - ok.addActionListener(this); - - this.add(eingabeName, "North"); - this.add(eingabeSurname, "North"); - this.add(eingabeAge, "North"); - this.add(sp, "Center"); - this.add(ok, "South"); - - } - - @Override - public void actionPerformed(ActionEvent e) { - - System.out.println("Kunde anlegen..."); - - try { - - bs.setCurrentKunde(bs.addNewKunde(eingabeName.getText(), eingabeSurname.getText(), - Integer.parseInt(eingabeAge.getText()))); - - this.ausgabe.append("Ihr Kundenkonto mit der ID [" + bs.getKundenID() + "] wurde erfolgreich angelegt.\n"); - - } catch (Exception e1) { - e1.printStackTrace(); - } - - } - -}