Fix: improved gui frames

gui
Caner Aliji 2022-12-01 15:59:31 +01:00
parent 0d4ec593e0
commit 930c6b96b3
3 changed files with 60 additions and 47 deletions

View File

@ -2,6 +2,7 @@ package de.hs_mannheim.informatik.bank;
import de.hs_mannheim.informatik.bank.facade.Banksystem; import de.hs_mannheim.informatik.bank.facade.Banksystem;
import de.hs_mannheim.informatik.bank.gui.HauptmenüFrame; import de.hs_mannheim.informatik.bank.gui.HauptmenüFrame;
import de.hs_mannheim.informatik.bank.gui.KundeAnlegen;
public class Main { public class Main {
@ -10,7 +11,9 @@ public class Main {
Banksystem bs = new Banksystem("Spaßkasse Mannheim"); 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);
} }

View File

@ -18,6 +18,7 @@ public class HauptmenüFrame extends JFrame implements ActionListener{
private JButton button; private JButton button;
private JButton button2; private JButton button2;
private JLabel label; private JLabel label;
private JLabel label2;
private Banksystem bs; private Banksystem bs;
@ -29,27 +30,33 @@ public class HauptmenüFrame extends JFrame implements ActionListener{
this.panel = new JPanel(); this.panel = new JPanel();
this.frame = new JFrame(); this.frame = new JFrame();
this.frame.setTitle(bs.getBankname() + " - Hauptmenü"); frame.setTitle(bs.getBankname() + " - Hauptmenü");
this.frame.setSize(400, 400); frame.setSize(300, 200);
this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.frame.add(panel); frame.setLocationRelativeTo(null);
this.panel.setLayout(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.label = new JLabel(bs.getBankname());
this.button.setBounds(10, 80, 300, 25); label.setBounds(10, 10, 200, 25);
this.button.addActionListener(this); panel.add(label);
this.panel.add(button);
this.button2 = new JButton("Neuen Kunden anlegen"); this.label2 = new JLabel("Hauptmenü");
this.button2.setBounds(10, 110, 300, 25); label2.setBounds(10, 30, 200, 25);
this.button2.addActionListener(this); panel.add(label2);
this.panel.add(button2);
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) { while(running) {
if(e.getSource() == button) { if(e.getSource() == button) {
this.frame.dispose(); frame.dispose();
LoginFrame loginFrame = new LoginFrame(bs); KundeAnlegen kundeAnlegen = new KundeAnlegen(bs);
running = false; running = false;
} }
if(e.getSource() == button2) { if(e.getSource() == button2) {
this.frame.dispose(); frame.dispose();
KundeAnlegen kundeAnlegen = new KundeAnlegen(bs); LoginFrame loginFrame = new LoginFrame(bs);
running = false; running = false;
} }

View File

@ -4,6 +4,7 @@ import javax.swing.JPanel;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.JTextField; import javax.swing.JTextField;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -38,47 +39,50 @@ public class KundeAnlegen extends JFrame implements ActionListener{
this.frame = new JFrame(); this.frame = new JFrame();
this.frame.setTitle(bs.getBankname() + " - Kunde anlegen"); frame.setTitle(bs.getBankname() + " - Kunde anlegen");
this.frame.setSize(400, 400); frame.setSize(400, 500);
this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.frame.add(panel); frame.setLocationRelativeTo(null);
this.panel.setLayout(null); frame.add(panel);
frame.setResizable(false);
panel.setLayout(null);
this.label = new JLabel("Name"); this.label = new JLabel("Name");
label.setBounds(10, 20, 80, 25); label.setBounds(10, 20, 80, 25);
this.panel.add(label); panel.add(label);
this.input = new JTextField(20); this.input = new JTextField(20);
this.input.setBounds(100, 20, 165, 25); input.setBounds(120, 20, 165, 20);
this.panel.add(input); panel.add(input);
this.label2 = new JLabel("Nachname"); this.label2 = new JLabel("Nachname");
label2.setBounds(10, 50, 80, 25); label2.setBounds(10, 50, 80, 25);
this.panel.add(label2); panel.add(label2);
this.input2 = new JTextField(20); this.input2 = new JTextField(20);
this.input2.setBounds(100, 50, 165, 25); input2.setBounds(120, 50, 165, 20);
this.panel.add(input2); panel.add(input2);
this.label3 = new JLabel("Alter"); this.label3 = new JLabel("Alter");
label3.setBounds(10, 80, 80, 25); label3.setBounds(10, 80, 80, 25);
this.panel.add(label3); panel.add(label3);
this.input3 = new JTextField(20); this.input3 = new JTextField(20);
this.input3.setBounds(100, 80, 165, 25); input3.setBounds(120, 80, 165, 20);
this.panel.add(input3); panel.add(input3);
this.output = new JTextArea(10, 20);
this.output.setBounds(10, 110, 300, 200);
this.output.setEditable(false);
this.panel.add(output);
this.button = new JButton("Kunde anlegen"); this.button = new JButton("Kunde anlegen");
button.addActionListener(this); button.addActionListener(this);
button.setBounds(10, 320, 300, 25); button.setBounds(120, 140, 165, 20);
this.panel.add(button); 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)); 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) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
@ -111,7 +114,7 @@ public class KundeAnlegen extends JFrame implements ActionListener{
} }
this.frame.dispose(); frame.dispose();
KontoAnlegenFrame kaf = new KontoAnlegenFrame(bs); KontoAnlegenFrame kaf = new KontoAnlegenFrame(bs);