New: gui frames / Fix: order of frames

gui
Caner 2022-12-03 18:53:18 +01:00
parent d09bf5386f
commit e2666fb5a2
6 changed files with 284 additions and 24 deletions

View File

@ -1,7 +1,11 @@
package de.hs_mannheim.informatik.bank;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
import de.hs_mannheim.informatik.bank.gui.AuswahlmenüSparkontoFrame;
import de.hs_mannheim.informatik.bank.gui.FehlerFrame;
import de.hs_mannheim.informatik.bank.gui.HauptmenüFrame;
import de.hs_mannheim.informatik.bank.gui.KontoauszugFrame;
import de.hs_mannheim.informatik.bank.gui.LoginFrame;
public class Main {
@ -9,7 +13,12 @@ public class Main {
Banksystem bs = new Banksystem("Spaßkasse Mannheim");
HauptmenüFrame hmf = new HauptmenüFrame(bs);
//HauptmenüFrame hmf = new HauptmenüFrame(bs);
//AuswahlmenüSparkontoFrame asf = new AuswahlmenüSparkontoFrame(bs);
KontoauszugFrame kaf = new KontoauszugFrame(bs);
}

View File

@ -72,35 +72,42 @@ public class AuswahlmenüFrame implements ActionListener {
if (e.getSource() == button) {
this.frame.dispose();
frame.dispose();
KontoAnlegenFrame kontoAnlegenFrame = new KontoAnlegenFrame(bs);
} else if (e.getSource() == button2) {
this.frame.dispose();
frame.dispose();
KontoListingFrame kontoListingFrame = new KontoListingFrame(bs);
} else if (e.getSource() == button3) {
this.frame.dispose();
frame.dispose();
GeldEinzahlenFrame geldEinzahlenFrame = new GeldEinzahlenFrame(bs);
}
else if (e.getSource() == button4) {
this.frame.dispose();
frame.dispose();
GeldAuszahlenFrame geldAuszahlenFrame = new GeldAuszahlenFrame(bs);
}
else if (e.getSource() == button5) {
this.frame.dispose();
frame.dispose();
HauptmenüFrame hauptmenüFrame = new HauptmenüFrame(bs);
}
else {
frame.dispose();
FehlerFrame fehlerFrame = new FehlerFrame(bs);
}
}
}

View File

@ -0,0 +1,124 @@
package de.hs_mannheim.informatik.bank.gui;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class AuswahlmenüSparkontoFrame implements ActionListener{
private JPanel panel;
private JFrame frame;
private JButton button;
private JButton button2;
private JButton button3;
private JButton button4;
private JButton button5;
private Banksystem bs;
public AuswahlmenüSparkontoFrame(Banksystem bs) {
this.bs = bs;
this.panel = new JPanel();
this.frame = new JFrame();
frame.setTitle(bs.getBankname() + " - Auswahlmenü Sparkonto");
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("Geld einzahlen");
button.setBounds(40, 50, 300, 25);
button.addActionListener(this);
panel.add(button);
this.button2 = new JButton("Geld abheben");
button2.setBounds(40, 80, 300, 25);
button2.addActionListener(this);
panel.add(button2);
this.button3 = new JButton("Kontoauszug");
button3.setBounds(40, 110, 300, 25);
button3.addActionListener(this);
panel.add(button3);
this.button4 = new JButton("Saldo");
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);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Sparkonto...");
if(e.getSource() == button) {
frame.dispose();
GeldEinzahlenFrame geldEinzahlenFrame = new GeldEinzahlenFrame(bs);
}
else if(e.getSource() == button2) {
frame.dispose();
GeldAuszahlenFrame geldAuszahlenFrame = new GeldAuszahlenFrame(bs);
}
else if(e.getSource() == button3) {
frame.dispose();
// TODO KontoauszugFrame
}
else if(e.getSource() == button4) {
frame.dispose();
// TODO SaldoFrame
}
else if(e.getSource() == button5) {
frame.dispose();
HauptmenüFrame hauptmenüFrame = new HauptmenüFrame(bs);
}
else {
frame.dispose();
FehlerFrame fehlerFrame = new FehlerFrame(bs);
}
}
}

View File

@ -2,24 +2,26 @@ 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.SwingConstants;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class LoginFehlerFrame implements ActionListener {
public class FehlerFrame implements ActionListener {
private JPanel panel;
private JFrame frame;
private JButton button;
private JTextArea output;
private JLabel label;
private JLabel label2;
private Banksystem bs;
public LoginFehlerFrame(Banksystem bs) {
public FehlerFrame(Banksystem bs) {
this.bs = bs;
@ -34,13 +36,20 @@ public class LoginFehlerFrame implements ActionListener {
frame.add(panel);
panel.setLayout(null);
this.output = new JTextArea("Fehler beim Login\nKunden-ID nicht gefunden");
output.setBounds(65, 50, 150, 35);
output.setEditable(false);
panel.add(output);
this.label = new JLabel("Ein Fehler ist aufgetreten");
label.setBounds(-10, 20, 300, 25);
label.setHorizontalAlignment(SwingConstants.CENTER);
panel.add(label);
this.button = new JButton("Zurück zum Login");
button.setBounds(65, 120, 150, 25);
this.label2 = new JLabel("Bitte kehren Sie zum Hauptmenü zurück.");
label2.setBounds(-10, 40, 300, 50);
label2.setHorizontalAlignment(SwingConstants.CENTER);
panel.add(label2);
this.button = new JButton("Zurück zum Hauptmenü");
button.setBounds(45, 120, 200, 25);
button.setHorizontalAlignment(SwingConstants.CENTER);
button.addActionListener(this);
panel.add(button);
@ -51,11 +60,11 @@ public class LoginFehlerFrame implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Loginfehler...");
System.out.println("Fehlermeldung...");
if (e.getSource() == button) {
frame.dispose();
LoginFrame lf = new LoginFrame(bs);
HauptmenüFrame hmf = new HauptmenüFrame(bs);
}
}

View File

@ -0,0 +1,97 @@
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.awt.event.ActionEvent;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class KontoauszugFrame implements ActionListener{
private JPanel panel;
private JFrame frame;
private JLabel label;
private JTextField input;
private JTextArea output;
private JButton button;
private Banksystem bs;
public KontoauszugFrame(Banksystem bs){
this.bs = bs;
this.panel = new JPanel();
this.frame = new JFrame();
frame.setTitle(bs.getBankname() + " - Kontoauszug");
frame.setSize(450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.add(panel);
panel.setLayout(null);
this.label = new JLabel("Kontonummer");
label.setBounds(10, 20, 100, 25);
panel.add(label);
this.input = new JTextField(20);
input.setBounds(100, 20, 60, 25);
panel.add(input);
this.output = new JTextArea();
output.setBounds(10, 50, 415, 200);
output.setEditable(false);
panel.add(output);
this.button = new JButton("Kontoauszug drucken");
button.setBounds(265, 20, 160, 25);
panel.add(button);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Kontoauszug drucken...");
try {
if(e.getSource() == button){
String[] kontoauszug = bs.erstelleKontoauszug(Integer.parseInt(input.getText()));
if(kontoauszug.length > 0) {
for(String ka : kontoauszug) {
output.append(ka + "\n");
}
} else {
output.setText("Keine Transaktionen vorhanden!");
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View File

@ -9,6 +9,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 LoginFrame implements ActionListener {
@ -18,6 +19,8 @@ public class LoginFrame implements ActionListener {
private JButton button;
private JTextField input;
private JLabel label;
private JTextField input2;
private JLabel label2;
private Banksystem bs;
@ -41,9 +44,17 @@ public class LoginFrame implements ActionListener {
panel.add(label);
this.input = new JTextField(20);
input.setBounds(80, 20, 120, 20);
input.setBounds(120, 20, 80, 20);
panel.add(input);
this.label2 = new JLabel("Kontonummer");
label2.setBounds(10, 47, 100, 25);
panel.add(label2);
this.input2 = new JTextField(20);
input2.setBounds(120, 50, 80, 20);
panel.add(input2);
this.button = new JButton("Login");
button.setBounds(100, 100, 80, 25);
button.addActionListener(this);
@ -58,21 +69,24 @@ public class LoginFrame implements ActionListener {
System.out.println("Login...");
int kundenID = Integer.parseInt(input.getText());
try {
bs.setCurrentKunde(bs.getKunde(kundenID));
bs.setCurrentKunde(bs.getKunde(Integer.parseInt(input.getText())));
if (bs.getCurrentKunde() != null) {
frame.dispose();
AuswahlmenüFrame auswahlmenü = new AuswahlmenüFrame(bs);
if(bs.checkKontoart(Integer.parseInt(input2.getText())).equals(Kontoart.Sparkonto)) {
frame.dispose();
AuswahlmenüSparkontoFrame amsf = new AuswahlmenüSparkontoFrame(bs);
}
} else {
frame.dispose();
LoginFehlerFrame lff = new LoginFehlerFrame(bs);
FehlerFrame lff = new FehlerFrame(bs);
}