New: KundeAnlegen panel

gui
Caner 2022-11-30 14:41:17 +01:00
parent 2b0940b5b5
commit c0967d7fa2
3 changed files with 115 additions and 75 deletions

View File

@ -1,7 +1,8 @@
package de.hs_mannheim.informatik.bank; 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.KundeAnlegenFrame;
import de.hs_mannheim.informatik.bank.gui.KundeAnlegen;
public class Main { public class Main {
@ -9,9 +10,9 @@ public class Main {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Banksystem bs = new Banksystem("Spaßkasse Mannheim"); Banksystem bs = new Banksystem("Spaßkasse Mannheim");
KundeAnlegenFrame kaf = new KundeAnlegenFrame(bs); KundeAnlegen tp = new KundeAnlegen(bs);
kaf.setVisible(true);
} }

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}