import je.NumberField;
import javafx.application.Application;
import javafx.event.*;
import javafx.scene.control.*;
import javafx.scene.input.*;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.Pane;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.text.*;
import javafx.scene.text.Font;

/**
 *
 * Beschreibung
 *
 * @version 1.0 vom 31.05.2022
 * @author Gerhard Röhner
 */

public class GuiBlockchainMitWallet extends Application {
  // Anfang Attribute
  private Label lBlockchain = new Label();
  private Label lWallets = new Label();
  private Pane pane1 = new Pane();
    private Label lBlock1 = new Label();
    private Label lSchwierigkeit1 = new Label();
    private Label lNonce1 = new Label();
    private NumberField nfNonce1 = new NumberField();
    private Label lDaten1 = new Label();
    private TextArea taDaten1 = new TextArea();
    private Label lHash1 = new Label();
    private TextField tfHash1 = new TextField();
    private Button bMine1 = new Button();
    private Spinner<Integer> spBlock1 = new Spinner<>(0, 10, 1, 1);
    private Label lVorher1 = new Label();
    private TextField tfVorherigerHash1 = new TextField();
    private Spinner<Integer> spSchwierigkeit1 = new Spinner<>(0, 10, 5, 1);
  private Pane pane2 = new Pane();
    private Label lBlock2 = new Label();
    private Label lSchwierigkeit2 = new Label();
    private Label lNonce2 = new Label();
    private NumberField nfNonce2 = new NumberField();
    private Label lDaten2 = new Label();
    private TextArea taDaten2 = new TextArea();
    private Label lHash2 = new Label();
    private TextField tfHash2 = new TextField();
    private Button bMine2 = new Button();
    private Label lVorher2 = new Label();
    private TextField tfVorherigerHash2 = new TextField();
    private Spinner<Integer> spBlock2 = new Spinner<>(0, 10, 2, 1);
    private Spinner<Integer> spSchwierigkeit2 = new Spinner<>(0, 10, 5, 1);
  private Pane pane3 = new Pane();
    private Label lBlock3 = new Label();
    private Label lSchwierigkeit3 = new Label();
    private Label lNonce3 = new Label();
    private NumberField nfNonce3 = new NumberField();
    private Label lDaten3 = new Label();
    private TextArea taDaten3 = new TextArea();
    private Label lHash3 = new Label();
    private TextField tfHash3 = new TextField();
    private Button bMine3 = new Button();
    private Label lVorher3 = new Label();
    private TextField tfVorherigerHash3 = new TextField();
    private Spinner<Integer> spBlock3 = new Spinner<>(0, 10, 3, 1);
    private Spinner<Integer> spSchwierigkeit3 = new Spinner<>(0, 10, 5, 1);
  private Pane pane4 = new Pane();
    private Label lBlock4 = new Label();
    private Label lSchwierigkeit4 = new Label();
    private Label lNonce4 = new Label();
    private NumberField nfNonce4 = new NumberField();
    private Label lDaten4 = new Label();
    private TextArea taDaten4 = new TextArea();
    private Label lHash4 = new Label();
    private TextField tfHash4 = new TextField();
    private Button bMine4 = new Button();
    private Label lVorher4 = new Label();
    private TextField tfVorherigerHash4 = new TextField();
    private Spinner<Integer> spBlock4 = new Spinner<>(0, 10, 4, 1);
    private Spinner<Integer> spSchwierigkeit4 = new Spinner<>(0, 10, 5, 1);
  private Pane paWallet1 = new Pane();
    private Label lEigentuemer = new Label();
    private TextField tfEigentuemer1 = new TextField();
    private Label lKontostand = new Label();
    private NumberField nfKontostand1 = new NumberField();
    private Label lBTC = new Label();
    private Label lTransaktion = new Label();
    private Label lEmpfaenger = new Label();
    private TextField tfEmpfaenger1 = new TextField();
    private Label lBetrag = new Label();
    private NumberField nfBetrag1 = new NumberField();
    private Label lBTC1 = new Label();
    private Button bAusfuehren1 = new Button();
  private Button bNeuerBlock = new Button();
  private Pane paWallet2 = new Pane();
    private Label lEigentuemer1 = new Label();
    private TextField tfEigentuemer2 = new TextField();
    private Label lKontostand1 = new Label();
    private NumberField nfKontostand2 = new NumberField();
    private Label lBTC2 = new Label();
    private Label lTransaktion1 = new Label();
    private Label lEmpfaenger1 = new Label();
    private TextField tfEmpfaenger2 = new TextField();
    private Label lBetrag1 = new Label();
    private NumberField nfBetrag2 = new NumberField();
    private Label lBTC3 = new Label();
    private Button bAusfuehren2 = new Button();
  // Ende Attribute
  private BlockChain eineBlockChain = new BlockChain(4);
  private int sichtbareBlöcke = 1;
  private Wallet Wallet1 = new Wallet("Gerhard", 10);
  private Wallet Wallet2 = new Wallet("Lutz", 8);
  
  public void start(Stage primaryStage) { 
    Pane root = new Pane();
    Scene scene = new Scene(root, 832, 942);
    // Anfang Komponenten
    
    pane1.setLayoutX(0);
    pane1.setLayoutY(40);
    pane1.setPrefHeight(224);
    pane1.setPrefWidth(500);
    root.getChildren().add(pane1);
    lBlock1.setLayoutX(208);
    lBlock1.setLayoutY(8);
    lBlock1.setPrefHeight(20);
    lBlock1.setPrefWidth(46);
    lBlock1.setText("Block");
    pane1.getChildren().add(lBlock1);
    lSchwierigkeit1.setLayoutX(344);
    lSchwierigkeit1.setLayoutY(8);
    lSchwierigkeit1.setPrefHeight(20);
    lSchwierigkeit1.setPrefWidth(86);
    lSchwierigkeit1.setText("Schwierigkeit");
    pane1.getChildren().add(lSchwierigkeit1);
    spSchwierigkeit1.setLayoutX(432);
    spSchwierigkeit1.setLayoutY(5);
    spSchwierigkeit1.setPrefHeight(27);
    spSchwierigkeit1.setPrefWidth(54);
    spSchwierigkeit1.setOnMouseClicked(
      (event) -> {spBlock_MouseClicked(event);} 
    );
    pane1.getChildren().add(spSchwierigkeit1);
    lNonce1.setLayoutX(8);
    lNonce1.setLayoutY(8);
    lNonce1.setPrefHeight(20);
    lNonce1.setPrefWidth(46);
    lNonce1.setText("Nonce");
    pane1.getChildren().add(lNonce1);
    nfNonce1.setLayoutX(56);
    nfNonce1.setLayoutY(6);
    nfNonce1.setPrefHeight(25);
    nfNonce1.setPrefWidth(75);
    nfNonce1.setOnKeyTyped(
      (event) -> {nfNonce_KeyTyped(event);} 
    );
    pane1.getChildren().add(nfNonce1);
    lDaten1.setLayoutX(8);
    lDaten1.setLayoutY(40);
    lDaten1.setPrefHeight(20);
    lDaten1.setPrefWidth(46);
    lDaten1.setText("Daten");
    pane1.getChildren().add(lDaten1);
    taDaten1.setLayoutX(56);
    taDaten1.setLayoutY(40);
    taDaten1.setPrefHeight(84);
    taDaten1.setPrefWidth(432);
    taDaten1.setOnKeyTyped(
      (event) -> {taDaten_KeyTyped(event);} 
    );
    pane1.getChildren().add(taDaten1);
    lHash1.setLayoutX(8);
    lHash1.setLayoutY(161);
    lHash1.setPrefHeight(20);
    lHash1.setPrefWidth(46);
    lHash1.setText("Hash");
    pane1.getChildren().add(lHash1);
    tfHash1.setLayoutX(56);
    tfHash1.setLayoutY(161);
    tfHash1.setPrefHeight(25);
    tfHash1.setPrefWidth(432);
    tfHash1.setEditable(false);
    pane1.getChildren().add(tfHash1);
    bMine1.setLayoutX(56);
    bMine1.setLayoutY(192);
    bMine1.setPrefHeight(25);
    bMine1.setPrefWidth(75);
    bMine1.setOnAction(
      (event) -> {bMine1_Action(event);} 
    );
    bMine1.setText("Mine");
    pane1.getChildren().add(bMine1);
    spBlock1.setLayoutX(248);
    spBlock1.setLayoutY(5);
    spBlock1.setPrefHeight(27);
    spBlock1.setPrefWidth(54);
    spBlock1.setOnMouseClicked(
      (event) -> {spBlock_MouseClicked(event);} 
    );
    pane1.getChildren().add(spBlock1);
    lVorher1.setLayoutX(8);
    lVorher1.setLayoutY(132);
    lVorher1.setPrefHeight(20);
    lVorher1.setPrefWidth(38);
    lVorher1.setText("Vorher");
    pane1.getChildren().add(lVorher1);
    tfVorherigerHash1.setLayoutX(56);
    tfVorherigerHash1.setLayoutY(132);
    tfVorherigerHash1.setPrefHeight(25);
    tfVorherigerHash1.setPrefWidth(432);
    tfVorherigerHash1.setEditable(false);
    pane1.getChildren().add(tfVorherigerHash1);

    pane2.setLayoutX(0);
    pane2.setLayoutY(264);
    pane2.setPrefHeight(224);
    pane2.setPrefWidth(500);
    pane2.setVisible(false);
    root.getChildren().add(pane2);
    lBlock2.setLayoutX(208);
    lBlock2.setLayoutY(8);
    lBlock2.setPrefHeight(20);
    lBlock2.setPrefWidth(46);
    lBlock2.setText("Block");
    pane2.getChildren().add(lBlock2);
    lSchwierigkeit2.setLayoutX(344);
    lSchwierigkeit2.setLayoutY(8);
    lSchwierigkeit2.setPrefHeight(20);
    lSchwierigkeit2.setPrefWidth(86);
    lSchwierigkeit2.setText("Schwierigkeit");
    pane2.getChildren().add(lSchwierigkeit2);
    spSchwierigkeit2.setLayoutX(432);
    spSchwierigkeit2.setLayoutY(5);
    spSchwierigkeit2.setPrefHeight(27);
    spSchwierigkeit2.setPrefWidth(54);
    spSchwierigkeit2.setOnMouseClicked(
      (event) -> {spBlock_MouseClicked(event);} 
    );
    pane2.getChildren().add(spSchwierigkeit2);
    lNonce2.setLayoutX(8);
    lNonce2.setLayoutY(8);
    lNonce2.setPrefHeight(20);
    lNonce2.setPrefWidth(46);
    lNonce2.setText("Nonce");
    pane2.getChildren().add(lNonce2);
    nfNonce2.setLayoutX(56);
    nfNonce2.setLayoutY(6);
    nfNonce2.setPrefHeight(25);
    nfNonce2.setPrefWidth(75);
    nfNonce2.setOnKeyTyped(
      (event) -> {nfNonce_KeyTyped(event);} 
    );    
    pane2.getChildren().add(nfNonce2);
    lDaten2.setLayoutX(8);
    lDaten2.setLayoutY(40);
    lDaten2.setPrefHeight(20);
    lDaten2.setPrefWidth(46);
    lDaten2.setText("Daten");
    pane2.getChildren().add(lDaten2);
    taDaten2.setLayoutX(56);
    taDaten2.setLayoutY(40);
    taDaten2.setPrefHeight(84);
    taDaten2.setPrefWidth(432);
    taDaten2.setOnKeyTyped(
      (event) -> {taDaten_KeyTyped(event);} 
    );
    pane2.getChildren().add(taDaten2);
    lHash2.setLayoutX(8);
    lHash2.setLayoutY(161);
    lHash2.setPrefHeight(20);
    lHash2.setPrefWidth(46);
    lHash2.setText("Hash");
    pane2.getChildren().add(lHash2);
    tfHash2.setLayoutX(56);
    tfHash2.setLayoutY(161);
    tfHash2.setPrefHeight(25);
    tfHash2.setPrefWidth(432);
    tfHash2.setEditable(false);
    pane2.getChildren().add(tfHash2);
    bMine2.setLayoutX(56);
    bMine2.setLayoutY(192);
    bMine2.setPrefHeight(25);
    bMine2.setPrefWidth(75);
    bMine2.setOnAction(
      (event) -> {bMine2_Action(event);} 
    );
    bMine2.setText("Mine");
    pane2.getChildren().add(bMine2);
    spBlock2.setLayoutX(248);
    spBlock2.setLayoutY(5);
    spBlock2.setPrefHeight(27);
    spBlock2.setPrefWidth(54);
    spBlock2.setOnMouseClicked(
      (event) -> {spBlock_MouseClicked(event);} 
    );
    pane2.getChildren().add(spBlock2);
    lVorher2.setLayoutX(8);
    lVorher2.setLayoutY(132);
    lVorher2.setPrefHeight(20);
    lVorher2.setPrefWidth(38);
    lVorher2.setText("Vorher");
    pane2.getChildren().add(lVorher2);
    tfVorherigerHash2.setLayoutX(56);
    tfVorherigerHash2.setLayoutY(132);
    tfVorherigerHash2.setPrefHeight(25);
    tfVorherigerHash2.setPrefWidth(432);
    tfVorherigerHash2.setEditable(false);
    pane2.getChildren().add(tfVorherigerHash2);
    pane3.setLayoutX(0);
    pane3.setLayoutY(488);
    pane3.setPrefHeight(224);
    pane3.setPrefWidth(500);
    pane3.setVisible(false);
    root.getChildren().add(pane3);
    lBlock3.setLayoutX(208);
    lBlock3.setLayoutY(8);
    lBlock3.setPrefHeight(20);
    lBlock3.setPrefWidth(46);
    lBlock3.setText("Block");
    pane3.getChildren().add(lBlock3);
    lSchwierigkeit3.setLayoutX(344);
    lSchwierigkeit3.setLayoutY(8);
    lSchwierigkeit3.setPrefHeight(20);
    lSchwierigkeit3.setPrefWidth(86);
    lSchwierigkeit3.setText("Schwierigkeit");
    pane3.getChildren().add(lSchwierigkeit3);
    spSchwierigkeit3.setLayoutX(432);
    spSchwierigkeit3.setLayoutY(5);
    spSchwierigkeit3.setPrefHeight(27);
    spSchwierigkeit3.setPrefWidth(54);
    spSchwierigkeit3.setOnMouseClicked(
      (event) -> {spBlock_MouseClicked(event);} 
    );
    pane3.getChildren().add(spSchwierigkeit3);
    lNonce3.setLayoutX(8);
    lNonce3.setLayoutY(8);
    lNonce3.setPrefHeight(20);
    lNonce3.setPrefWidth(46);
    lNonce3.setText("Nonce");
    pane3.getChildren().add(lNonce3);
    nfNonce3.setLayoutX(56);
    nfNonce3.setLayoutY(6);
    nfNonce3.setPrefHeight(25);
    nfNonce3.setPrefWidth(75);
    nfNonce3.setOnKeyTyped(
      (event) -> {nfNonce_KeyTyped(event);} 
    );
    pane3.getChildren().add(nfNonce3);
    lDaten3.setLayoutX(8);
    lDaten3.setLayoutY(40);
    lDaten3.setPrefHeight(20);
    lDaten3.setPrefWidth(46);
    lDaten3.setText("Daten");
    pane3.getChildren().add(lDaten3);
    taDaten3.setLayoutX(56);
    taDaten3.setLayoutY(40);
    taDaten3.setPrefHeight(84);
    taDaten3.setPrefWidth(432);
    taDaten3.setOnKeyTyped(
      (event) -> {taDaten_KeyTyped(event);} 
    );
    pane3.getChildren().add(taDaten3);
    lHash3.setLayoutX(8);
    lHash3.setLayoutY(161);
    lHash3.setPrefHeight(20);
    lHash3.setPrefWidth(46);
    lHash3.setText("Hash");
    pane3.getChildren().add(lHash3);
    tfHash3.setLayoutX(56);
    tfHash3.setLayoutY(161);
    tfHash3.setPrefHeight(25);
    tfHash3.setPrefWidth(432);
    tfHash3.setEditable(false);
    pane3.getChildren().add(tfHash3);
    bMine3.setLayoutX(56);
    bMine3.setLayoutY(192);
    bMine3.setPrefHeight(25);
    bMine3.setPrefWidth(75);
    bMine3.setOnAction(
      (event) -> {bMine3_Action(event);} 
    );
    bMine3.setText("Mine");
    pane3.getChildren().add(bMine3);
    spBlock3.setLayoutX(248);
    spBlock3.setLayoutY(5);
    spBlock3.setPrefHeight(27);
    spBlock3.setPrefWidth(54);
    spBlock3.setOnMouseClicked(
      (event) -> {spBlock_MouseClicked(event);} 
    );
    pane3.getChildren().add(spBlock3);
    lVorher3.setLayoutX(8);
    lVorher3.setLayoutY(132);
    lVorher3.setPrefHeight(20);
    lVorher3.setPrefWidth(38);
    lVorher3.setText("Vorher");
    pane3.getChildren().add(lVorher3);
    tfVorherigerHash3.setLayoutX(56);
    tfVorherigerHash3.setLayoutY(132);
    tfVorherigerHash3.setPrefHeight(25);
    tfVorherigerHash3.setPrefWidth(432);
    tfVorherigerHash3.setEditable(false);
    pane3.getChildren().add(tfVorherigerHash3);
    pane4.setLayoutX(0);
    pane4.setLayoutY(712);
    pane4.setPrefHeight(224);
    pane4.setPrefWidth(500);
    pane4.setVisible(false);
    root.getChildren().add(pane4);
    lBlock4.setLayoutX(208);
    lBlock4.setLayoutY(8);
    lBlock4.setPrefHeight(20);
    lBlock4.setPrefWidth(46);
    lBlock4.setText("Block");
    pane4.getChildren().add(lBlock4);
    lSchwierigkeit4.setLayoutX(344);
    lSchwierigkeit4.setLayoutY(8);
    lSchwierigkeit4.setPrefHeight(20);
    lSchwierigkeit4.setPrefWidth(86);
    lSchwierigkeit4.setText("Schwierigkeit");
    pane4.getChildren().add(lSchwierigkeit4);
    spSchwierigkeit4.setLayoutX(432);
    spSchwierigkeit4.setLayoutY(5);
    spSchwierigkeit4.setPrefHeight(27);
    spSchwierigkeit4.setPrefWidth(54);
    spSchwierigkeit4.setOnMouseClicked(
      (event) -> {spBlock_MouseClicked(event);} 
    );
    pane4.getChildren().add(spSchwierigkeit4);
    lNonce4.setLayoutX(8);
    lNonce4.setLayoutY(8);
    lNonce4.setPrefHeight(20);
    lNonce4.setPrefWidth(46);
    lNonce4.setText("Nonce");
    pane4.getChildren().add(lNonce4);
    nfNonce4.setLayoutX(56);
    nfNonce4.setLayoutY(6);
    nfNonce4.setPrefHeight(25);
    nfNonce4.setPrefWidth(75);
    nfNonce3.setOnKeyTyped(
      (event) -> {nfNonce_KeyTyped(event);} 
    );    
    pane4.getChildren().add(nfNonce4);
    lDaten4.setLayoutX(8);
    lDaten4.setLayoutY(40);
    lDaten4.setPrefHeight(20);
    lDaten4.setPrefWidth(46);
    lDaten4.setText("Daten");
    pane4.getChildren().add(lDaten4);
    taDaten4.setLayoutX(56);
    taDaten4.setLayoutY(40);
    taDaten4.setPrefHeight(84);
    taDaten4.setPrefWidth(432);
    taDaten4.setOnKeyTyped(
      (event) -> {taDaten_KeyTyped(event);} 
    );
    pane4.getChildren().add(taDaten4);
    lHash4.setLayoutX(8);
    lHash4.setLayoutY(161);
    lHash4.setPrefHeight(20);
    lHash4.setPrefWidth(46);
    lHash4.setText("Hash");
    pane4.getChildren().add(lHash4);
    tfHash4.setLayoutX(56);
    tfHash4.setLayoutY(161);
    tfHash4.setPrefHeight(25);
    tfHash4.setPrefWidth(432);
    tfHash4.setEditable(false);
    pane4.getChildren().add(tfHash4);
    bMine4.setLayoutX(56);
    bMine4.setLayoutY(192);
    bMine4.setPrefHeight(25);
    bMine4.setPrefWidth(75);
    bMine4.setOnAction(
      (event) -> {bMine4_Action(event);} 
    );
    bMine4.setText("Mine");
    pane4.getChildren().add(bMine4);
    spBlock4.setLayoutX(248);
    spBlock4.setLayoutY(5);
    spBlock4.setPrefHeight(27);
    spBlock4.setPrefWidth(54);
    spBlock4.setOnMouseClicked(
      (event) -> {spBlock_MouseClicked(event);} 
    );
    pane4.getChildren().add(spBlock4);
    lVorher4.setLayoutX(8);
    lVorher4.setLayoutY(132);
    lVorher4.setPrefHeight(20);
    lVorher4.setPrefWidth(38);
    lVorher4.setText("Vorher");
    pane4.getChildren().add(lVorher4);
    tfVorherigerHash4.setLayoutX(56);
    tfVorherigerHash4.setLayoutY(132);
    tfVorherigerHash4.setPrefHeight(25);
    tfVorherigerHash4.setPrefWidth(432);
    tfVorherigerHash4.setEditable(false);
    pane4.getChildren().add(tfVorherigerHash4);
    tfVorherigerHash4.setEditable(false);
        
    primaryStage.setOnShowing(
      (event) -> {primaryStage_Showing(event);} 
    );
    lBlockchain.setLayoutX(176);
    lBlockchain.setLayoutY(8);
    lBlockchain.setPrefHeight(20);
    lBlockchain.setPrefWidth(110);
    lBlockchain.setText("Blockchain");
    lBlockchain.setFont(Font.font("Dialog", 18));
    root.getChildren().add(lBlockchain);
    lWallets.setLayoutX(632);
    lWallets.setLayoutY(8);
    lWallets.setPrefHeight(20);
    lWallets.setPrefWidth(110);
    lWallets.setText("Wallets");
    lWallets.setFont(Font.font("Dialog", 18));
    root.getChildren().add(lWallets);
    paWallet1.setLayoutX(520);
    paWallet1.setLayoutY(40);
    paWallet1.setPrefHeight(204);
    paWallet1.setPrefWidth(300);
    paWallet1.setStyle("-fx-border-color: gray; -fx-border-width: 2; -fx-border-style: solid;");
    root.getChildren().add(paWallet1);
    lEigentuemer.setLayoutX(8);
    lEigentuemer.setLayoutY(10);
    lEigentuemer.setPrefHeight(20);
    lEigentuemer.setPrefWidth(78);
    tfEigentuemer1.setLayoutX(88);
    tfEigentuemer1.setLayoutY(8);
    tfEigentuemer1.setPrefHeight(25);
    tfEigentuemer1.setPrefWidth(150);
    lKontostand.setLayoutX(8);
    lKontostand.setLayoutY(42);
    lKontostand.setPrefHeight(20);
    lKontostand.setPrefWidth(78);
    nfKontostand1.setLayoutX(88);
    nfKontostand1.setLayoutY(40);
    nfKontostand1.setPrefHeight(25);
    nfKontostand1.setPrefWidth(150);
    lBTC.setLayoutX(248);
    lBTC.setLayoutY(42);
    lBTC.setPrefHeight(20);
    lBTC.setPrefWidth(38);
    lTransaktion.setLayoutX(8);
    lTransaktion.setLayoutY(80);
    lTransaktion.setPrefHeight(20);
    lTransaktion.setPrefWidth(110);
    lEmpfaenger.setLayoutX(8);
    lEmpfaenger.setLayoutY(106);
    lEmpfaenger.setPrefHeight(20);
    lEmpfaenger.setPrefWidth(78);
    tfEmpfaenger1.setLayoutX(88);
    tfEmpfaenger1.setLayoutY(104);
    tfEmpfaenger1.setPrefHeight(25);
    tfEmpfaenger1.setPrefWidth(150);
    lBetrag.setLayoutX(8);
    lBetrag.setLayoutY(136);
    lBetrag.setPrefHeight(20);
    lBetrag.setPrefWidth(78);
    nfBetrag1.setLayoutX(88);
    nfBetrag1.setLayoutY(136);
    nfBetrag1.setPrefHeight(25);
    nfBetrag1.setPrefWidth(150);
    lBTC1.setLayoutX(248);
    lBTC1.setLayoutY(138);
    lBTC1.setPrefHeight(20);
    lBTC1.setPrefWidth(38);
    bAusfuehren1.setLayoutX(120);
    bAusfuehren1.setLayoutY(171);
    bAusfuehren1.setPrefHeight(25);
    bAusfuehren1.setPrefWidth(91);
    lEigentuemer.setText("Eigentümer");
    paWallet1.getChildren().add(lEigentuemer);
    paWallet1.getChildren().add(tfEigentuemer1);
    lKontostand.setText("Kontostand");
    paWallet1.getChildren().add(lKontostand);
    paWallet1.getChildren().add(nfKontostand1);
    lBTC.setText("BTC");
    paWallet1.getChildren().add(lBTC);
    lTransaktion.setText("Transaktion");
    paWallet1.getChildren().add(lTransaktion);
    lEmpfaenger.setText("Empfänger");
    paWallet1.getChildren().add(lEmpfaenger);
    tfEmpfaenger1.setText("Doris");
    paWallet1.getChildren().add(tfEmpfaenger1);
    lBetrag.setText("Betrag");
    paWallet1.getChildren().add(lBetrag);
    nfBetrag1.setText("2");
    paWallet1.getChildren().add(nfBetrag1);
    lBTC1.setText("BTC");
    paWallet1.getChildren().add(lBTC1);
    bAusfuehren1.setOnAction(
      (event) -> {bAusfuehren1_Action(event);} 
    );
    bAusfuehren1.setText("Ausführen");
    paWallet1.getChildren().add(bAusfuehren1);
    bNeuerBlock.setLayoutX(520);
    bNeuerBlock.setLayoutY(504);
    bNeuerBlock.setPrefHeight(25);
    bNeuerBlock.setPrefWidth(115);
    bNeuerBlock.setOnAction(
      (event) -> {bNeuerBlock_Action(event);} 
    );
    bNeuerBlock.setText("Neuer Block");
    root.getChildren().add(bNeuerBlock);
    paWallet2.setLayoutX(520);
    paWallet2.setLayoutY(280);
    paWallet2.setPrefHeight(204);
    paWallet2.setPrefWidth(300);
    paWallet2.setStyle("-fx-border-color: gray; -fx-border-width: 2; -fx-border-style: solid;");
    root.getChildren().add(paWallet2);
    lEigentuemer1.setLayoutX(8);
    lEigentuemer1.setLayoutY(10);
    lEigentuemer1.setPrefHeight(20);
    lEigentuemer1.setPrefWidth(78);
    lEigentuemer1.setText("Eigentümer");
    paWallet2.getChildren().add(lEigentuemer1);
    tfEigentuemer2.setLayoutX(88);
    tfEigentuemer2.setLayoutY(8);
    tfEigentuemer2.setPrefHeight(25);
    tfEigentuemer2.setPrefWidth(150);
    paWallet2.getChildren().add(tfEigentuemer2);
    lKontostand1.setLayoutX(8);
    lKontostand1.setLayoutY(42);
    lKontostand1.setPrefHeight(20);
    lKontostand1.setPrefWidth(78);
    lKontostand1.setText("Kontostand");
    paWallet2.getChildren().add(lKontostand1);
    nfKontostand2.setLayoutX(88);
    nfKontostand2.setLayoutY(40);
    nfKontostand2.setPrefHeight(25);
    nfKontostand2.setPrefWidth(150);
    paWallet2.getChildren().add(nfKontostand2);
    lBTC2.setLayoutX(248);
    lBTC2.setLayoutY(42);
    lBTC2.setPrefHeight(20);
    lBTC2.setPrefWidth(38);
    lBTC2.setText("BTC");
    paWallet2.getChildren().add(lBTC2);
    lTransaktion1.setLayoutX(8);
    lTransaktion1.setLayoutY(80);
    lTransaktion1.setPrefHeight(20);
    lTransaktion1.setPrefWidth(110);
    lTransaktion1.setText("Transaktion");
    paWallet2.getChildren().add(lTransaktion1);
    lEmpfaenger1.setLayoutX(8);
    lEmpfaenger1.setLayoutY(106);
    lEmpfaenger1.setPrefHeight(20);
    lEmpfaenger1.setPrefWidth(78);
    lEmpfaenger1.setText("Empfänger");
    paWallet2.getChildren().add(lEmpfaenger1);
    tfEmpfaenger2.setLayoutX(88);
    tfEmpfaenger2.setLayoutY(104);
    tfEmpfaenger2.setPrefHeight(25);
    tfEmpfaenger2.setPrefWidth(150);
    tfEmpfaenger2.setText("");
    paWallet2.getChildren().add(tfEmpfaenger2);
    lBetrag1.setLayoutX(8);
    lBetrag1.setLayoutY(136);
    lBetrag1.setPrefHeight(20);
    lBetrag1.setPrefWidth(78);
    lBetrag1.setText("Betrag");
    paWallet2.getChildren().add(lBetrag1);
    nfBetrag2.setLayoutX(88);
    nfBetrag2.setLayoutY(136);
    nfBetrag2.setPrefHeight(25);
    nfBetrag2.setPrefWidth(150);
    nfBetrag2.setText("");
    paWallet2.getChildren().add(nfBetrag2);
    lBTC3.setLayoutX(248);
    lBTC3.setLayoutY(138);
    lBTC3.setPrefHeight(20);
    lBTC3.setPrefWidth(38);
    lBTC3.setText("BTC");
    paWallet2.getChildren().add(lBTC3);
    bAusfuehren2.setLayoutX(120);
    bAusfuehren2.setLayoutY(171);
    bAusfuehren2.setPrefHeight(25);
    bAusfuehren2.setPrefWidth(91);
    bAusfuehren2.setOnAction(
      (event) -> {bAusfuehren2_Action(event);} 
    );
    bAusfuehren2.setText("Ausführen");
    paWallet2.getChildren().add(bAusfuehren2);
    // Ende Komponenten
    
    primaryStage.setAlwaysOnTop(false);
    primaryStage.setOnCloseRequest(e -> System.exit(0));
    primaryStage.setTitle("GuiBlockchainMitWallet");
    primaryStage.setScene(scene);
    primaryStage.show();
  } 
  
  // Anfang Methoden
  
  public static void main(String[] args) {
    launch(args);
  } // end of main
  
  public void primaryStage_Showing(Event evt) {
    String _64Nullen = "0000000000000000000000000000000000000000000000000000000000000000";
    eineBlockChain.NeuerBlock(1, 210274, _64Nullen, "");
    eineBlockChain.NeuerBlock(2, 210274, _64Nullen, "");
    eineBlockChain.NeuerBlock(3, 210274, _64Nullen, "");
    eineBlockChain.NeuerBlock(4, 210274, _64Nullen, "");
    ModelToView();
  } 
  
  public void setNonce(NumberField Nonce, int value) {
    int p = Nonce.getCaretPosition();
    Nonce.setInt(value);
    Nonce.positionCaret(p);
  }
  
  public void setText(TextArea Area, String value) {
    int p = Area.getCaretPosition();
    Area.setText(value);
    Area.positionCaret(p);
  }  

  public void ModelToView() {
    Block einBlock = eineBlockChain.getBlock(1);
    setNonce(nfNonce1, einBlock.getNonce());
    setText(taDaten1, einBlock.getDaten());
    tfVorherigerHash1.setText(einBlock.getVorgängerHash());
    tfHash1.setText(einBlock.getHash());
    ZeigeGültigkeit(einBlock.gültig(), pane1);

    einBlock = eineBlockChain.getBlock(2);
    setNonce(nfNonce2, einBlock.getNonce());   
    setText(taDaten2, einBlock.getDaten());
    tfVorherigerHash2.setText(einBlock.getVorgängerHash());
    tfHash2.setText(einBlock.getHash());
    ZeigeGültigkeit(einBlock.gültig(), pane2);
    
    einBlock = eineBlockChain.getBlock(3);
    setNonce(nfNonce3, einBlock.getNonce());
    setText(taDaten3, einBlock.getDaten());
    tfVorherigerHash3.setText(einBlock.getVorgängerHash());
    tfHash3.setText(einBlock.getHash());
    ZeigeGültigkeit(einBlock.gültig(), pane3);
    
    einBlock = eineBlockChain.getBlock(4);
    setNonce(nfNonce4, einBlock.getNonce());
    setText(taDaten4, einBlock.getDaten());
    tfVorherigerHash4.setText(einBlock.getVorgängerHash());
    tfHash4.setText(einBlock.getHash());
    ZeigeGültigkeit(einBlock.gültig(), pane4); 
    
    tfEigentuemer1.setText(Wallet1.getEigentümer());
    nfKontostand1.setDouble(Wallet1.getKontostand());
    
    tfEigentuemer2.setText(Wallet2.getEigentümer());
    nfKontostand2.setDouble(Wallet2.getKontostand());    
    // paWallet1.setStyle("");    
  }
  
  public void ViewToModel() {
    Block einBlock = eineBlockChain.getBlock(1);
    einBlock.setNonce(nfNonce1.getInt());
    einBlock.setNr(spBlock1.getValue());
    einBlock.setSchwierigkeit(spSchwierigkeit1.getValue());
    einBlock.setDaten(taDaten1.getText());
    einBlock.berechneHash();
    
    einBlock = eineBlockChain.getBlock(2);
    einBlock.setNonce(nfNonce2.getInt());
    einBlock.setNr(spBlock2.getValue());
    einBlock.setSchwierigkeit(spSchwierigkeit2.getValue());
    einBlock.setDaten(taDaten2.getText());
    einBlock.setVorgängerHash(eineBlockChain.getBlock(1).getHash());
    einBlock.berechneHash();
    
    einBlock = eineBlockChain.getBlock(3);
    einBlock.setNonce(nfNonce3.getInt());
    einBlock.setNr(spBlock3.getValue());
    einBlock.setSchwierigkeit(spSchwierigkeit3.getValue());
    einBlock.setDaten(taDaten3.getText());
    einBlock.setVorgängerHash(eineBlockChain.getBlock(2).getHash());
    einBlock.berechneHash();
    
    einBlock = eineBlockChain.getBlock(4);
    einBlock.setNonce(nfNonce4.getInt());
    einBlock.setNr(spBlock4.getValue());
    einBlock.setSchwierigkeit(spSchwierigkeit4.getValue());
    einBlock.setDaten(taDaten4.getText());
    einBlock.setVorgängerHash(eineBlockChain.getBlock(3).getHash());
    einBlock.berechneHash();
  } 
  
  public void ZeigeGültigkeit(boolean gültig, Pane aPane) {
    if (gültig)
      aPane.setStyle("-fx-background-color: #DBF0D4;");
    else 
      aPane.setStyle("-fx-background-color: #F7D9D9;");
  }
  
  public void bMine1_Action(Event evt) {
    ViewToModel();
    eineBlockChain.getBlock(1).mine();
    ModelToView();
  } 

  public void bMine2_Action(Event evt) {
    ViewToModel();
    eineBlockChain.getBlock(2).mine();
    ModelToView();    
  } 

  public void bMine3_Action(Event evt) {
    ViewToModel();
    eineBlockChain.getBlock(3).mine();
    ModelToView();    
  } 

  public void bMine4_Action(Event evt) {
    ViewToModel();
    eineBlockChain.getBlock(4).mine();
    ModelToView(); 
  } 

  public void nfNonce_KeyTyped(KeyEvent evt) {
    ViewToModel();
    ModelToView();
  } 

  public void spBlock_MouseClicked(MouseEvent evt) {
    ViewToModel();
    ModelToView();
  } 

  public void taDaten_KeyTyped(KeyEvent evt) {
    ViewToModel();
    ModelToView();
  } 
  
  public void bAusfuehren1_Action(Event evt) {
    String Empfänger = tfEmpfaenger1.getText();
    double Betrag = nfBetrag1.getDouble();
    String Transaktion = Wallet1.erstelleTransaktion(Empfänger, Betrag);
    String Signatur = Wallet1.signieren(Transaktion);
    Wallet1.TransaktionAusführen();
    Block aktuellerBlock = eineBlockChain.getBlock(sichtbareBlöcke);
    String Daten = aktuellerBlock.getDaten() + "\n" + Transaktion + "\n" + Signatur;
    if (Wallet1.verifizieren(Transaktion, Wallet1.getPublicKeyBase64(), Signatur))
      Daten = Daten + "\nSignatur verifiziert";
    else
      Daten = Daten + "\nSignatur nicht verifziert";
    eineBlockChain.getBlock(sichtbareBlöcke).setDaten(Daten);
    ModelToView();
  } 
  
  public void bAusfuehren2_Action(Event evt) {
    String Empfänger = tfEmpfaenger2.getText();
    double Betrag = nfBetrag2.getDouble();
    String Transaktion = Wallet2.erstelleTransaktion(Empfänger, Betrag);
    String Signatur = Wallet2.signieren(Transaktion);
    Wallet2.TransaktionAusführen();
    Block aktuellerBlock = eineBlockChain.getBlock(sichtbareBlöcke);
    String Daten = aktuellerBlock.getDaten() + "\n" + Transaktion + "\n" + Signatur;
    if (Wallet2.verifizieren(Transaktion, Wallet2.getPublicKeyBase64(), Signatur))
      Daten = Daten + "\nSignatur verifiziert";
    else
      Daten = Daten + "\nSignatur nicht verifziert";
    eineBlockChain.getBlock(sichtbareBlöcke).setDaten(Daten);
    ModelToView();
  } 
  
  public void bNeuerBlock_Action(Event evt) {
    if (sichtbareBlöcke < 4) {
      String Hash = eineBlockChain.getBlock(sichtbareBlöcke).getHash();
      sichtbareBlöcke++;
      switch (sichtbareBlöcke) {
        case 2: 
          pane2.setVisible(true);
          break;
        case 3: 
          pane3.setVisible(true);
          break;
        case 4: 
          pane4.setVisible(true);
          break;
        default: 
          
      } // end of switch
      eineBlockChain.getBlock(sichtbareBlöcke).setVorgängerHash(Hash);     
      ModelToView();
    }
  } 

  // Ende Methoden
} // end of class GuiBlockchainMitWallet
