New: added/changed frames

gui
Caner 2022-11-30 15:36:01 +01:00
parent c0967d7fa2
commit cdbd93c610
5 changed files with 189 additions and 56 deletions

View File

@ -1,7 +1,9 @@
package de.hs_mannheim.informatik.bank;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
import de.hs_mannheim.informatik.bank.gui.GeldEinzahlenFrame;
import de.hs_mannheim.informatik.bank.gui.KontoAnlegenFrame;
import de.hs_mannheim.informatik.bank.gui.KontoListingFrame;
import de.hs_mannheim.informatik.bank.gui.KundeAnlegen;
@ -11,8 +13,13 @@ public class Main {
Banksystem bs = new Banksystem("Spaßkasse Mannheim");
KundeAnlegen tp = new KundeAnlegen(bs);
KundeAnlegen ka = new KundeAnlegen(bs);
KontoAnlegenFrame kaf = new KontoAnlegenFrame(bs);
KontoListingFrame klf = new KontoListingFrame(bs);
GeldEinzahlenFrame gef = new GeldEinzahlenFrame(bs);
}

View File

@ -0,0 +1,93 @@
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 GeldEinzahlenFrame extends JFrame implements ActionListener {
private JPanel panel;
private JFrame frame;
private JLabel label;
private JLabel label2;
private JTextField input;
private JTextField input2;
private JTextArea output;
private JButton button;
private Banksystem bs;
public GeldEinzahlenFrame(Banksystem bs){
this.bs = bs;
this.panel = new JPanel();
this.frame = new JFrame();
this.frame.setTitle(bs.getBankname() + " - Geld einzahlen");
this.frame.setSize(400, 400);
this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.frame.add(panel);
this.panel.setLayout(null);
this.label = new JLabel("Kontonummer");
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("Betrag");
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.output = new JTextArea();
this.output.setBounds(10, 110, 300, 200);
this.output.setEditable(false);
this.panel.add(output);
this.button = new JButton("Einzahlen");
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("Geld einzahlen...");
Double betrag = Double.parseDouble(input2.getText());
try {
bs.geldEinzahlen(Integer.parseInt(input.getText()), (long) (betrag * 100));
this.output.append("Einzahlung von " + input2.getText() + " erfolgreich\nNeuer Kontostand beträgt " + (bs.getKontostand(Integer.parseInt(input.getText())) / 100) + " €\n");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View File

@ -5,18 +5,23 @@ import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import de.hs_mannheim.informatik.bank.domain.Kontoart;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class KontoAnlegenFrame extends JFrame implements ActionListener {
private JTextField eingabe;
private JTextArea ausgabe;
private JButton ok;
private JPanel panel;
private JFrame frame;
private JButton button;
private JButton button2;
private JButton button3;
private JTextArea output;
private Banksystem bs;
@ -24,24 +29,35 @@ public class KontoAnlegenFrame extends JFrame implements ActionListener {
this.bs = bs;
this.setTitle(bs.getBankname());
this.setSize(400, 300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.panel = new JPanel();
eingabe = new JTextField(20);
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);
ausgabe = new JTextArea(10, 20);
ausgabe.setLineWrap(true);
ausgabe.setWrapStyleWord(true);
this.button = new JButton("Girokonto");
this.button.setBounds(10, 80, 80, 25);
this.button.addActionListener(this);
this.panel.add(button);
JScrollPane sp = new JScrollPane(ausgabe);
this.button2 = new JButton("Sparkonto");
this.button2.setBounds(100, 80, 80, 25);
this.button2.addActionListener(this);
this.panel.add(button2);
ok = new JButton("Konto anlegen");
ok.addActionListener(this);
this.button3 = new JButton("Depot");
this.button3.setBounds(190, 80, 80, 25);
this.button3.addActionListener(this);
this.panel.add(button3);
this.add(eingabe, "North");
this.add(sp, "Center");
this.add(ok, "South");
this.output = new JTextArea(20, 20);
this.output.setBounds(10, 110, 300, 200);
this.output.setEditable(false);
this.panel.add(output);
this.frame.setVisible(true);
}
@ -49,19 +65,36 @@ public class KontoAnlegenFrame extends JFrame implements ActionListener {
public void actionPerformed(ActionEvent e) {
System.out.println("Konto anlegen...");
boolean running = true;
try {
while(running) {
int knr = bs.kontoAnlegen(bs.getCurrentKunde(), Kontoart.Sparkonto);
try {
this.ausgabe.append("Neus Konto angelegt: " + knr + "\n");
} catch (Exception e1) {
e1.printStackTrace();
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();
}
running = false;
}
}

View File

@ -5,17 +5,19 @@ import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class KontoListingFrame extends JFrame implements ActionListener{
private JTextField eingabe;
private JTextArea ausgabe;
private JButton ok;
private JPanel panel;
private JFrame frame;
private JButton button;
private JTextArea output;
private Banksystem bs;
@ -23,24 +25,26 @@ public class KontoListingFrame extends JFrame implements ActionListener{
this.bs = bs;
this.setTitle(bs.getBankname());
this.setSize(300, 300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
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);
eingabe = new JTextField(20);
this.button = new JButton("Kontoliste abrufen");
this.button.setBounds(10, 80, 160, 25);
this.button.addActionListener(this);
this.panel.add(button);
ausgabe = new JTextArea(5, 20);
ausgabe.setLineWrap(true);
ausgabe.setWrapStyleWord(true);
this.output = new JTextArea(20, 20);
this.output.setBounds(10, 110, 300, 200);
this.output.setEditable(false);
this.panel.add(output);
JScrollPane sp = new JScrollPane(ausgabe);
ok = new JButton("Kontenliste abrufen");
ok.addActionListener(this);
this.add(eingabe, "North");
this.add(sp, "Center");
this.add(ok, "South");
this.frame.setVisible(true);
}
@ -48,13 +52,11 @@ public class KontoListingFrame extends JFrame implements ActionListener{
public void actionPerformed(ActionEvent e) {
System.out.println("Kontenliste abrufen...");
ausgabe.setText("");
String[] konten = bs.getKontenlisteForKunde();
for (String konto : konten) {
ausgabe.append(konto + "\n");
}
for(String konto : konten){
this.output.append(konto + "\n");
}
}
}

View File

@ -38,7 +38,7 @@ public class KundeAnlegen extends JFrame implements ActionListener{
this.frame = new JFrame();
this.frame.setTitle(bs.getBankname());
this.frame.setTitle(bs.getBankname() + " - Kunde anlegen");
this.frame.setSize(400, 400);
this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.frame.add(panel);
@ -70,8 +70,6 @@ public class KundeAnlegen extends JFrame implements ActionListener{
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);