diff --git a/src/main/java/Enigma/GuiController.java b/src/main/java/Enigma/GuiController.java index 71168fabbf990f8b4c1486219b445fd33face139..c94198ebfea95570495d0c17f5d34f240bc043b0 100644 --- a/src/main/java/Enigma/GuiController.java +++ b/src/main/java/Enigma/GuiController.java @@ -1,10 +1,14 @@ package Enigma; +import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.*; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.paint.Color; -import java.awt.event.ActionEvent; import java.util.ArrayList; public class GuiController { @@ -96,6 +100,85 @@ public class GuiController { @FXML private Button btnLöschen; + @FXML + private Button btnP1; + + @FXML + private Button btnY1; + + @FXML + private Button btnX1; + + @FXML + private Button btnC1; + + @FXML + private Button btnV1; + + @FXML + private Button btnB1; + + @FXML + private Button btnN1; + + @FXML + private Button btnM1; + + @FXML + private Button btnL1; + + @FXML + private Button btnA1; + + @FXML + private Button btnS1; + + @FXML + private Button btnD1; + + @FXML + private Button btnF1; + + @FXML + private Button btnG1; + + @FXML + private Button btnH1; + + @FXML + private Button btnJ1; + + @FXML + private Button btnK1; + + @FXML + private Button btnQ1; + + @FXML + private Button btnW1; + + @FXML + private Button btnE1; + + @FXML + private Button btnR1; + + @FXML + private Button btnT1; + + @FXML + private Button btnZ1; + + @FXML + private Button btnU1; + + @FXML + private Button btnI1; + + @FXML + private Button btnO1; + + @FXML private MenuButton mBtnWalzPos1; @@ -160,9 +243,18 @@ public class GuiController { @FXML private TextField tfStecker10; -// @FXML -// void gedrueckteTaste() { -// } + @FXML + void leuchtTaste(MouseEvent e) { + while (e.getSource() == btnA){ + + btnA1.setStyle("-fx-background-color: #ff0000"); + + // setText(btnA); + } + + + } + @FXML void btnempfangen() { @@ -200,16 +292,6 @@ public class GuiController { }); } } - - @FXML - private Button btnQ1; - @FXML - void gedrueckteTasteQ() { - btnQ1.setStyle("-fx-background-color: #ff0000"); - //btnQ2.setStyle("-fx-background-color: #ffffff"); - - } - @FXML void initialize() { //Einträge für Walzen @@ -264,8 +346,10 @@ public class GuiController { assert tfcodiert != null : "fx:id=\"tfcodiert\" was not injected: check your FXML file 'gui.fxml'."; assert mBtnNotchPos1 != null : "fx:id=\"mBtnNotchPos1\" was not injected: check your FXML file 'gui.fxml'."; - // ActionListener den Butten hinzufügen - btnA.setOnAction(e -> {gedrueckteTaste(e);}); +/* ActionListener den Butten hinzufügen + btnA.setOnAction(e -> { + gedrueckteTaste(e); + }); btnB.setOnAction(e -> {gedrueckteTaste(e);}); btnC.setOnAction(e -> {gedrueckteTaste(e);}); btnD.setOnAction(e -> {gedrueckteTaste(e);}); @@ -291,13 +375,79 @@ public class GuiController { btnX.setOnAction(e -> {gedrueckteTaste(e);}); btnY.setOnAction(e -> {gedrueckteTaste(e);}); btnZ.setOnAction(e -> {gedrueckteTaste(e);}); + + + btnA.setOnMouseEntered (e->{ + leuchtTaste(e); + }); + + btnA1.setOnMouseDragEntered (e -> {leuchtTaste(e);}); + btnB1.setOnAction(e -> {gedrueckteTaste(e);}); + btnC1.setOnAction(e -> {gedrueckteTaste(e);}); + btnD1.setOnAction(e -> {gedrueckteTaste(e);}); + btnE1.setOnAction(e -> {gedrueckteTaste(e);}); + btnF1.setOnAction(e -> {gedrueckteTaste(e);}); + btnG1.setOnAction(e -> {gedrueckteTaste(e);}); + btnH1.setOnAction(e -> {gedrueckteTaste(e);}); + btnI1.setOnAction(e -> {gedrueckteTaste(e);}); + btnJ1.setOnAction(e -> {gedrueckteTaste(e);}); + btnK1.setOnAction(e -> {gedrueckteTaste(e);}); + btnL1.setOnAction(e -> {gedrueckteTaste(e);}); + btnM1.setOnAction(e -> {gedrueckteTaste(e);}); + btnN1.setOnAction(e -> {gedrueckteTaste(e);}); + btnO1.setOnAction(e -> {gedrueckteTaste(e);}); + btnP1.setOnAction(e -> {gedrueckteTaste(e);}); + btnQ1.setOnAction(e -> {gedrueckteTaste(e);}); + btnR1.setOnAction(e -> {gedrueckteTaste(e);}); + btnS1.setOnAction(e -> {gedrueckteTaste(e);}); + btnT1.setOnAction(e -> {gedrueckteTaste(e);}); + btnU1.setOnAction(e -> {gedrueckteTaste(e);}); + btnV1.setOnAction(e -> {gedrueckteTaste(e);}); + btnW1.setOnAction(e -> {gedrueckteTaste(e);}); + btnX1.setOnAction(e -> {gedrueckteTaste(e);}); + btnY1.setOnAction(e -> {gedrueckteTaste(e);}); + btnZ1.setOnAction(e -> {gedrueckteTaste(e);});*/ + + leuchten(btnA, btnA1); + leuchten(btnB, btnB1); + leuchten(btnC,btnC1); + leuchten(btnD, btnD1); + leuchten(btnE, btnE1); + leuchten(btnF, btnF1); + leuchten(btnG, btnG1); + leuchten(btnH, btnH1); + leuchten(btnI, btnI1); + leuchten(btnJ,btnJ1); + leuchten(btnK, btnK1); + leuchten(btnL, btnL1); + leuchten(btnM, btnM1); + leuchten(btnN, btnN1); + leuchten(btnO, btnO1); + leuchten(btnP, btnP1); + leuchten(btnQ,btnQ1); + leuchten(btnR, btnR1); + leuchten(btnS, btnS1); + leuchten(btnT, btnT1); + leuchten(btnU, btnU1); + leuchten(btnV, btnV1); + leuchten(btnW, btnW1); + leuchten(btnX,btnX1); + leuchten(btnY, btnY1); + leuchten(btnZ, btnZ1); } + + + /** * Auswertung welcher Button gedrückt wurde * @param e => ActionEvent des auslösenden Button */ @FXML - private void gedrueckteTaste(javafx.event.ActionEvent e) { + // private void gedrueckteTaste(javafx.event.ActionEvent e) { + + + private void gedrueckteTaste(ActionEvent e) { + //TODO Anbindung an Klasse Hardware if (e.getSource() == btnA) setText(btnA); if (e.getSource() == btnB) setText(btnB); @@ -337,6 +487,16 @@ public class GuiController { } } + private void leuchten(Button taste, Button leuchte){ + taste.setOnMousePressed(mouseEvent -> { + leuchte.setStyle("-fx-background-color: #FFA500"); + }); + taste.setOnMouseReleased(mouseEvent -> { + //btnA1.setBackground(Background.EMPTY); + leuchte.setStyle("-fx-background-color: "+ taste.getBackground()); + }); + } + /** * Setzt die Anzeige des entsprechende Gui-Element auf die entsprechende Walze * ->d.h. welche Walze sitzt auf welcher Position diff --git a/src/main/resources/Enigma/gui.fxml b/src/main/resources/Enigma/gui.fxml index 71d5c9ace219f81a101ad8567bad99456cd9a44f..fc579bdc36786a3fd52f03a254a2aa3261483f3f 100644 --- a/src/main/resources/Enigma/gui.fxml +++ b/src/main/resources/Enigma/gui.fxml @@ -6,6 +6,8 @@ <?import javafx.scene.control.MenuButton?> <?import javafx.scene.control.TextField?> <?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.paint.RadialGradient?> +<?import javafx.scene.paint.Stop?> <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="677.0" prefWidth="967.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Enigma.GuiController"> <children> @@ -115,40 +117,48 @@ <Label layoutX="380.0" layoutY="27.0" prefHeight="17.0" prefWidth="172.0" text="Tageseinstellungen" /> <ButtonBar layoutX="-15.0" layoutY="408.0" prefHeight="36.0" prefWidth="860.0"> <buttons> - <Button fx:id="btnP1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="P" /> - <Button fx:id="btnY1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="Y" /> - <Button fx:id="btnX1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="X" /> - <Button fx:id="btnC1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="C" /> - <Button fx:id="btnV1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="V" /> - <Button fx:id="btnB1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="B" /> - <Button fx:id="btnN1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="N" /> - <Button fx:id="btnM1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="M" /> - <Button fx:id="btnL1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="L" /> + <Button fx:id="btnP1" mnemonicParsing="false" onAction="#leuchtTaste" text="P" /> + <Button fx:id="btnY1" mnemonicParsing="false" onAction="#leuchtTaste" text="Y" /> + <Button fx:id="btnX1" mnemonicParsing="false" onAction="#leuchtTaste" text="X" /> + <Button fx:id="btnC1" mnemonicParsing="false" onAction="#leuchtTaste" text="C" /> + <Button fx:id="btnV1" mnemonicParsing="false" onAction="#leuchtTaste" text="V" /> + <Button fx:id="btnB1" mnemonicParsing="false" onAction="#leuchtTaste" text="B" /> + <Button fx:id="btnN1" mnemonicParsing="false" onAction="#leuchtTaste" text="N" /> + <Button fx:id="btnM1" mnemonicParsing="false" onAction="#leuchtTaste" text="M" /> + <Button fx:id="btnL1" mnemonicParsing="false" onAction="#leuchtTaste" text="L" /> </buttons> </ButtonBar> <ButtonBar layoutX="-63.0" layoutY="364.0" prefHeight="36.0" prefWidth="860.0"> <buttons> - <Button fx:id="btnA1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="A" /> - <Button fx:id="btnS1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="S" /> - <Button fx:id="btnD1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="D" /> - <Button fx:id="btnF1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="F" /> - <Button fx:id="btnG1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="G" /> - <Button fx:id="btnH1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="H" /> - <Button fx:id="btnJ1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="J" /> - <Button fx:id="btnK1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="K" /> + <Button fx:id="btnA1" mnemonicParsing="false" onAction="#leuchtTaste" text="A" /> + <Button fx:id="btnS1" mnemonicParsing="false" onAction="#leuchtTaste" text="S" /> + <Button fx:id="btnD1" mnemonicParsing="false" onAction="#leuchtTaste" text="D"> + <textFill> + <RadialGradient centerX="0.5" centerY="0.5" radius="0.5"> + <stops> + <Stop color="BLACK" /> + <Stop color="WHITE" offset="1.0" /> + </stops> + </RadialGradient> + </textFill></Button> + <Button fx:id="btnF1" mnemonicParsing="false" onAction="#leuchtTaste" text="F" /> + <Button fx:id="btnG1" mnemonicParsing="false" onAction="#leuchtTaste" text="G" /> + <Button fx:id="btnH1" mnemonicParsing="false" onAction="#leuchtTaste" text="H" /> + <Button fx:id="btnJ1" mnemonicParsing="false" onAction="#leuchtTaste" text="J" /> + <Button fx:id="btnK1" mnemonicParsing="false" onAction="#leuchtTaste" text="K" /> </buttons> </ButtonBar> <ButtonBar layoutX="46.0" layoutY="328.0" prefHeight="25.0" prefWidth="583.0"> <buttons> - <Button fx:id="btnQ1" minWidth="13.0" mnemonicParsing="false" onAction="#gedrueckteTasteQ" prefHeight="25.0" text="Q" /> - <Button fx:id="btnW1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="W" /> - <Button fx:id="btnE1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="E" /> - <Button fx:id="btnR1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="R" /> - <Button fx:id="btnT1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="T" /> - <Button fx:id="btnZ1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="Z" /> - <Button fx:id="btnU1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="U" /> - <Button fx:id="btnI1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="I" /> - <Button fx:id="btnO1" mnemonicParsing="false" onAction="#gedrueckteTaste" text="O" /> + <Button fx:id="btnQ1" disable="true" minWidth="26.0" mnemonicParsing="false" onAction="#leuchtTaste" prefHeight="25.0" text="Q" textFill="#544d4d" /> + <Button fx:id="btnW1" mnemonicParsing="false" onAction="#leuchtTaste" text="W" /> + <Button fx:id="btnE1" mnemonicParsing="false" onAction="#leuchtTaste" text="E" /> + <Button fx:id="btnR1" mnemonicParsing="false" onAction="#leuchtTaste" text="R" /> + <Button fx:id="btnT1" mnemonicParsing="false" onAction="#leuchtTaste" text="T" /> + <Button fx:id="btnZ1" mnemonicParsing="false" onAction="#leuchtTaste" text="Z" /> + <Button fx:id="btnU1" mnemonicParsing="false" onAction="#leuchtTaste" text="U" /> + <Button fx:id="btnI1" mnemonicParsing="false" onAction="#leuchtTaste" text="I" /> + <Button fx:id="btnO1" mnemonicParsing="false" onAction="#leuchtTaste" text="O" /> </buttons> </ButtonBar> </children>