Skip to content
Snippets Groups Projects
Commit 7f82f754 authored by Dennis Eisold's avatar Dennis Eisold
Browse files

Merge branch 'master' into 'master'

Master

See merge request alfatrainingkurse/java/enigma!85
parents a9565240 73b9f074
No related branches found
No related tags found
No related merge requests found
package projekt.enigma;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
/**
* JavaFX App
*/
public class App extends Application {
/**
* TODO Dokumentieren
*/
private static Scene scene;
/**
* TODO Dokumentieren
*
* @param fxml
* @throws IOException
*/
static void setRoot(String fxml) throws IOException {
scene.setRoot(loadFXML(fxml));
}
/**
* TODO Dokumentieren
*
* @param fxml
* @return
* @throws IOException
*/
private static Parent loadFXML(String fxml) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));
return fxmlLoader.load();
}
/**
* TODO Dokumentieren
*
* @param args
*/
public static void main(String[] args) {
Application.launch();
}
/**
* TODO Dokumentieren
*
* @param stage
* @throws IOException
*/
@Override
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("kenngruppe"));
stage.setScene(scene);
stage.setResizable(true);
stage.show();
}
}
package projekt.enigma; package projekt.enigma;
import java.awt.event.ActionEvent;
import java.io.IOException; import java.io.IOException;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.stage.Stage;
import projekt.enigma.model.Codierer; import projekt.enigma.model.Codierer;
public class KenngruppeController { public class KenngruppeController {
private Codierer cod = new Codierer(); private Codierer cod = new Codierer();
private Stage stage;
@FXML @FXML
private TextField tfKenngruppe; private TextField tfKenngruppe;
@FXML //TODO: Doku
private Button btnswitch;
// @FXML
// private void switchToPrimary() throws IOException {
// if (tfKenngruppe.getText().length() <= 8) {
// for (char c : tfKenngruppe.getText().toCharArray()) {
// if (c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f' || c == 'g' || c == 'h' || c == 'i' || c == 'j' || c == 'k' || c == 'l' || c == 'm' || c == 'n' || c == 'o' || c == 'p' || c == 'q' || c == 'r' || c == 's' || c == 't' || c == 'u' || c == 'v' || c == 'w' || c == 'x' || c == 'y' || c == 'z') {
// cod.setKenngruppe(tfKenngruppe.getText());
//
// App.setRoot("gui");
// }
// }
// } else {
// tfKenngruppe.setStyle("-fx-background-color:#FF0000");
// tfKenngruppe.setText("Fehlerhafte Kenngruppe!");
// }
// }
private Scene secondScene;
public void setSecondScene(Scene scene){
secondScene=scene;
}
/**
* Beim drücken der Taste wird überprüft ob die eingegebene Kenngruppe weniger als 9 Zeichen hat und ob die
* eingegebenen Zeichen nur Buchstaben sind.
* Bei einer gültigen Eingabe wird die eingegebene Kenngruppe gespeichert und die Enigma-Anwendung gestartet
* @throws IOException :
*/
@FXML @FXML
private void switchToPrimary(ActionEvent ae) throws IOException { private void btnGui() throws IOException {
Stage primaryStage = (Stage)((Node)ae.getSource()).getScene().getWindow(); if (tfKenngruppe.getText().length() <9) {
primaryStage.setScene(secondScene); for (char c : tfKenngruppe.getText().toCharArray()) {
if (c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f' || c == 'g' || c == 'h' || c == 'i' || c == 'j' || c == 'k' || c == 'l' || c == 'm' || c == 'n' || c == 'o' || c == 'p' || c == 'q' || c == 'r' || c == 's' || c == 't' || c == 'u' || c == 'v' || c == 'w' || c == 'x' || c == 'y' || c == 'z'||c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J' || c == 'K' || c == 'L' || c == 'M' || c == 'N' || c == 'O' || c == 'P' || c == 'Q' || c == 'R' || c == 'S' || c == 'T' || c == 'U' || c == 'V' || c == 'W' || c == 'X' || c == 'Y' || c == 'Z') {
cod.setKenngruppe(tfKenngruppe.getText());
//setzt
App.setRoot("gui");
}
}
} else {
tfKenngruppe.setStyle("-fx-background-color:#FF0000");
tfKenngruppe.setText("Fehlerhafte Kenngruppe!");
}
} }
} }
...@@ -7,26 +7,14 @@ ...@@ -7,26 +7,14 @@
<?import javafx.scene.control.TextField?> <?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?> <?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.Circle?> <?import javafx.scene.shape.Circle?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="677.0" prefWidth="962.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="projekt.enigma.GuiController"> <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="677.0" prefWidth="962.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="projekt.enigma.GuiController">
<children> <children>
<AnchorPane layoutX="241.0" layoutY="130.0" prefHeight="111.0" prefWidth="487.0" AnchorPane.leftAnchor="241.0" AnchorPane.rightAnchor="240.0"> <AnchorPane layoutX="207.0" layoutY="-111.0" prefHeight="111.0" prefWidth="487.0" AnchorPane.leftAnchor="207.0" AnchorPane.rightAnchor="274.0" />
<children>
<VBox layoutX="72.0" layoutY="-89.0" prefHeight="210.0" prefWidth="377.0" AnchorPane.bottomAnchor="-10.0" AnchorPane.leftAnchor="72.0" AnchorPane.rightAnchor="37.0" AnchorPane.topAnchor="-89.0">
<children>
<TextField fx:id="tfKlartext" editable="false" prefHeight="80.0" prefWidth="377.0" />
<Label prefHeight="17.0" prefWidth="385.0" />
<TextField fx:id="tfCodiert" editable="false" prefHeight="79.0" prefWidth="377.0" />
<Label prefHeight="17.0" prefWidth="385.0" />
</children>
</VBox>
</children></AnchorPane>
<GridPane layoutX="23.0" layoutY="60.0" prefHeight="158.0" prefWidth="237.0" AnchorPane.leftAnchor="23.0" AnchorPane.topAnchor="60.0"> <GridPane layoutX="23.0" layoutY="60.0" prefHeight="158.0" prefWidth="237.0" AnchorPane.leftAnchor="23.0" AnchorPane.topAnchor="60.0">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
...@@ -92,13 +80,6 @@ ...@@ -92,13 +80,6 @@
</MenuButton> </MenuButton>
</children> </children>
</GridPane> </GridPane>
<FlowPane layoutX="736.0" layoutY="51.0" prefHeight="173.0" prefWidth="195.0" AnchorPane.rightAnchor="36.0" AnchorPane.topAnchor="51.0">
<children>
<Button fx:id="btnEmpfangen" mnemonicParsing="false" onAction="#gedrueckteTaste" prefHeight="80.0" prefWidth="195.0" text="Funkspruch empfangen" />
<Label prefHeight="17.0" prefWidth="195.0" />
<Button fx:id="btnSenden" mnemonicParsing="false" onAction="#gedrueckteTaste" prefHeight="80.0" prefWidth="195.0" text="An Funker senden" />
</children>
</FlowPane>
<GridPane layoutX="23.0" layoutY="222.0" prefHeight="60.0" prefWidth="270.0" AnchorPane.leftAnchor="23.0" AnchorPane.topAnchor="222.0"> <GridPane layoutX="23.0" layoutY="222.0" prefHeight="60.0" prefWidth="270.0" AnchorPane.leftAnchor="23.0" AnchorPane.topAnchor="222.0">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="206.0" minWidth="10.0" prefWidth="102.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="206.0" minWidth="10.0" prefWidth="102.0" />
...@@ -690,5 +671,34 @@ ...@@ -690,5 +671,34 @@
</Label> </Label>
</children> </children>
</GridPane> </GridPane>
<Label layoutX="684.0" layoutY="-164.0" prefHeight="17.0" prefWidth="195.0" />
<GridPane layoutX="297.0" layoutY="64.0" prefHeight="168.0" prefWidth="585.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField fx:id="tfKlartext" editable="false" prefHeight="70.0" prefWidth="293.0">
<GridPane.margin>
<Insets />
</GridPane.margin>
</TextField>
<TextField fx:id="tfCodiert" editable="false" prefHeight="70.0" prefWidth="293.0" GridPane.rowIndex="1" />
<Button fx:id="btnSenden" alignment="CENTER" contentDisplay="RIGHT" mnemonicParsing="false" onAction="#gedrueckteTaste" prefHeight="70.0" prefWidth="195.0" text="An Funker senden" textAlignment="CENTER" GridPane.columnIndex="1">
<GridPane.margin>
<Insets left="80.0" />
</GridPane.margin>
</Button>
<Button fx:id="btnEmpfangen" mnemonicParsing="false" onAction="#gedrueckteTaste" prefHeight="70.0" prefWidth="195.0" text="Funkspruch empfangen" GridPane.columnIndex="1" GridPane.rowIndex="1">
<GridPane.margin>
<Insets left="80.0" />
</GridPane.margin>
</Button>
</children>
</GridPane>
</children> </children>
</AnchorPane> </AnchorPane>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<Label prefHeight="62.0" prefWidth="209.0" /> <Label prefHeight="62.0" prefWidth="209.0" />
<TextField fx:id="tfKenngruppe" /> <TextField fx:id="tfKenngruppe" />
<Label prefHeight="39.0" prefWidth="209.0" /> <Label prefHeight="39.0" prefWidth="209.0" />
<Button fx:id="btnswitch" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" onAction="#switchToPrimary" prefHeight="25.0" prefWidth="212.0" text="Kenngruppe setzen!" /> <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" onAction="#btnGui" prefHeight="25.0" prefWidth="212.0" text="Kenngruppe setzen!" />
</children> </children>
</VBox> </VBox>
</children> </children>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment