diff --git a/src/main/java/projekt/enigma/App.java b/src/main/java/projekt/enigma/App.java index eff5d686c3144f8f32d639b336b25cc855998093..9e05616af19c780bbce8111c26621b7c4e31f9e5 100644 --- a/src/main/java/projekt/enigma/App.java +++ b/src/main/java/projekt/enigma/App.java @@ -4,7 +4,12 @@ import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.VBox; import javafx.stage.Stage; +import projekt.enigma.model.Codierer; import java.io.IOException; @@ -15,60 +20,109 @@ import java.io.IOException; */ public class App extends Application { - /** - * TODO Dokumentieren - * - * scene : Scene : deklariert die Scene der GUI - */ - private static Scene scene; - - /** - * TODO Dokumentieren - * setzt die fxml-Datei - * - * @param fxml : String : Ort der fxml - * @throws IOException : wirft Exception, wenn die Datei nicht gefunden/geladen werden konnte - */ - static void setRoot(String fxml) throws IOException { - scene.setRoot(loadFXML(fxml)); - } + Scene sce1, sce2; + + @Override + public void start(Stage primaryStage) throws IOException { + + Codierer cod = new Codierer(); + + primaryStage.setTitle("Kenngruppenabfrage"); + +//Scene 1 + Label label1= new Label("Bitte Kenngruppe eingeben!"); + label1.setTranslateX(55); + Label l1=new Label(""); + Label l2 = new Label(""); + TextField tfield=new TextField(); + Button button1= new Button("Kenngruppe setzen!"); + + VBox layout1 = new VBox(); + // kc.btnGui(primaryStage, sce2); + button1.setOnAction(e -> { + if (tfield.getText().length() < 9) { + for (char c : tfield.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(tfield.getText()); + primaryStage.setScene(sce2); + } + } + }else{ + tfield.setStyle("-fx-background-color:#FF0000"); + tfield.setText("Fehlerhafte Kenngruppe!"); + } + }); + layout1.getChildren().addAll(label1,l1,tfield,l2,button1); + + //sce1= new Scene(loadFXML("kenngruppe"), 300, 250); - /** - * TODO Dokumentieren - * laedt die fxml-Datei - * - * @param fxml : String : Ort der fxml - * @return fxml wird geladen - * @throws IOException : wirft Exception, wenn die Datei nicht gefunden/geladen werden konnte - */ - private static Parent loadFXML(String fxml) throws IOException { + sce1=new Scene(layout1,234,137); + + sce2 = new Scene(loadFXML("gui"), 962, 677); + + primaryStage.setScene(sce1); + primaryStage.show(); + } + + private static Parent loadFXML(String fxml) throws IOException { FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml")); return fxmlLoader.load(); } - /** - * TODO Dokumentieren - * Standard-main-Methode, die die erweiterte Klasse Application startet - * - * @param args : String[] : Terminalparameter - */ - public static void main(String[] args) { - Application.launch(); - } - /** - * TODO Dokumentieren - * Deklariert und initialisiert die Stage. - * - * @param stage : Stage : Aufbau der Stage in der Scene - * @throws IOException : wirft Exception, wenn die Datei nicht gefunden/geladen werden konnte - */ - @Override - public void start(Stage stage) throws IOException { - scene = new Scene(loadFXML("kenngruppe")); - stage.setScene(scene); - stage.setResizable(true); - stage.show(); - } + public static void main(String[] args) { + launch(args); + } + + +// /** +// * 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(); +// } } diff --git a/src/main/java/projekt/enigma/KenngruppeController.java b/src/main/java/projekt/enigma/KenngruppeController.java index 714cc678814f83bc46c2b81ba1f82eb97d49e8d0..beb6b985ef6821feeec3732754f7bc6a8e0b1d38 100644 --- a/src/main/java/projekt/enigma/KenngruppeController.java +++ b/src/main/java/projekt/enigma/KenngruppeController.java @@ -35,7 +35,7 @@ public class KenngruppeController { if (tfKenngruppe.getText().length() < 9 && !error) { cod.setKenngruppe(tfKenngruppe.getText().toUpperCase()); //setzt - App.setRoot("gui"); + // App.setRoot("gui"); } else { tfKenngruppe.setStyle("-fx-background-color:#FF0000"); tfKenngruppe.setText("Fehlerhafte Kenngruppe!");