From 930c6b96b3cd6fe41b0d074060f905809872dc52 Mon Sep 17 00:00:00 2001 From: 212179 <2121719@stud.hs-mannheim.de> Date: Thu, 1 Dec 2022 15:59:31 +0100 Subject: [PATCH] Fix: improved gui frames --- .../de/hs_mannheim/informatik/bank/Main.java | 5 +- .../informatik/bank/gui/HauptmenüFrame.java | 49 +++++++++-------- .../informatik/bank/gui/KundeAnlegen.java | 53 ++++++++++--------- 3 files changed, 60 insertions(+), 47 deletions(-) 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 07dfcba..b13d568 100644 --- a/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/Main.java +++ b/Bank-Beispiel/src/de/hs_mannheim/informatik/bank/Main.java @@ -2,6 +2,7 @@ package de.hs_mannheim.informatik.bank; import de.hs_mannheim.informatik.bank.facade.Banksystem; import de.hs_mannheim.informatik.bank.gui.HauptmenüFrame; +import de.hs_mannheim.informatik.bank.gui.KundeAnlegen; public class Main { @@ -10,7 +11,9 @@ public class Main { Banksystem bs = new Banksystem("Spaßkasse Mannheim"); - HauptmenüFrame hmf = new HauptmenüFrame(bs); + //HauptmenüFrame hmf = new HauptmenüFrame(bs); + + KundeAnlegen ka = new KundeAnlegen(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 2b541f2..580c705 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 @@ -18,6 +18,7 @@ public class HauptmenüFrame extends JFrame implements ActionListener{ private JButton button; private JButton button2; private JLabel label; + private JLabel label2; private Banksystem bs; @@ -29,27 +30,33 @@ public class HauptmenüFrame extends JFrame implements ActionListener{ this.panel = new JPanel(); this.frame = new JFrame(); - this.frame.setTitle(bs.getBankname() + " - Hauptmenü"); - this.frame.setSize(400, 400); - this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.frame.add(panel); - this.panel.setLayout(null); + frame.setTitle(bs.getBankname() + " - Hauptmenü"); + frame.setSize(300, 200); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLocationRelativeTo(null); + frame.add(panel); + panel.setLayout(null); - this.label = new JLabel("Hauptmenü"); - label.setBounds(10, 20, 80, 25); - this.panel.add(label); - this.button = new JButton("Bei bestehendem Kundenkonto einloggen"); - this.button.setBounds(10, 80, 300, 25); - this.button.addActionListener(this); - this.panel.add(button); + this.label = new JLabel(bs.getBankname()); + label.setBounds(10, 10, 200, 25); + panel.add(label); - this.button2 = new JButton("Neuen Kunden anlegen"); - this.button2.setBounds(10, 110, 300, 25); - this.button2.addActionListener(this); - this.panel.add(button2); + this.label2 = new JLabel("Hauptmenü"); + label2.setBounds(10, 30, 200, 25); + panel.add(label2); - this.frame.setVisible(true); + this.button = new JButton("Neuen Kunden anlegen"); + button.setBounds(1, 80, 300, 25); + button.addActionListener(this); + panel.add(button); + + this.button2 = new JButton("Bei bestehendem Kunden einloggen"); + button2.setBounds(1, 110, 300, 25); + button2.addActionListener(this); + panel.add(button2); + + frame.setVisible(true); } @@ -62,14 +69,14 @@ public class HauptmenüFrame extends JFrame implements ActionListener{ while(running) { if(e.getSource() == button) { - this.frame.dispose(); - LoginFrame loginFrame = new LoginFrame(bs); + frame.dispose(); + KundeAnlegen kundeAnlegen = new KundeAnlegen(bs); running = false; } if(e.getSource() == button2) { - this.frame.dispose(); - KundeAnlegen kundeAnlegen = new KundeAnlegen(bs); + frame.dispose(); + LoginFrame loginFrame = new LoginFrame(bs); running = false; } 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 dff81ad..ec9640c 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 @@ -4,6 +4,7 @@ import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; + import java.awt.event.ActionListener; import java.awt.event.ActionEvent; @@ -38,47 +39,50 @@ public class KundeAnlegen extends JFrame implements ActionListener{ this.frame = new JFrame(); - this.frame.setTitle(bs.getBankname() + " - Kunde anlegen"); - this.frame.setSize(400, 400); - this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.frame.add(panel); - this.panel.setLayout(null); + frame.setTitle(bs.getBankname() + " - Kunde anlegen"); + frame.setSize(400, 500); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLocationRelativeTo(null); + frame.add(panel); + frame.setResizable(false); + panel.setLayout(null); this.label = new JLabel("Name"); label.setBounds(10, 20, 80, 25); - this.panel.add(label); + panel.add(label); this.input = new JTextField(20); - this.input.setBounds(100, 20, 165, 25); - this.panel.add(input); + input.setBounds(120, 20, 165, 20); + panel.add(input); this.label2 = new JLabel("Nachname"); label2.setBounds(10, 50, 80, 25); - this.panel.add(label2); + panel.add(label2); this.input2 = new JTextField(20); - this.input2.setBounds(100, 50, 165, 25); - this.panel.add(input2); + input2.setBounds(120, 50, 165, 20); + panel.add(input2); this.label3 = new JLabel("Alter"); label3.setBounds(10, 80, 80, 25); - this.panel.add(label3); + 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.setEditable(false); - this.panel.add(output); + input3.setBounds(120, 80, 165, 20); + panel.add(input3); this.button = new JButton("Kunde anlegen"); button.addActionListener(this); - button.setBounds(10, 320, 300, 25); - this.panel.add(button); + button.setBounds(120, 140, 165, 20); + panel.add(button); - this.frame.setVisible(true); + this.output = new JTextArea(); + output.setBounds(10, 170, 380, 290); + output.setEditable(false); + panel.add(output); + + + frame.setVisible(true); } @@ -98,9 +102,8 @@ public class KundeAnlegen extends JFrame implements ActionListener{ bs.setCurrentKunde(bs.addNewKunde(name, surname, age)); - this.output.append("Ihr Kundenkonto mit der ID [" + bs.getKundenID() + "] wurde erfolgreich angelegt.\n"); + output.append("Ihr Kundenkonto mit der ID [" + bs.getKundenID() + "] wurde erfolgreich angelegt.\n"); - break; } catch (Exception ex) { ex.printStackTrace(); @@ -111,7 +114,7 @@ public class KundeAnlegen extends JFrame implements ActionListener{ } - this.frame.dispose(); + frame.dispose(); KontoAnlegenFrame kaf = new KontoAnlegenFrame(bs);