Skip to content
Snippets Groups Projects
Commit b7407ffe authored by Jan Schubert's avatar Jan Schubert
Browse files

fxml Datei

parent 1ca47123
No related branches found
No related tags found
No related merge requests found
package projekt.enigma;
import projekt.enigma.model.Codierer;
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("gui"));
stage.setScene(scene);
stage.setResizable(true);
stage.show();
}
}
package projekt.enigma;
import java.awt.event.ActionEvent;
import java.io.IOException;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import projekt.enigma.model.Codierer;
public class KenngruppeController {
private Codierer cod = new Codierer();
private Stage stage;
@FXML
private void switchToPrimary() throws IOException {
App.setRoot("gui");
private TextField tfKenngruppe;
@FXML
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;
}
@FXML
private void switchToPrimary(ActionEvent ae) throws IOException {
Stage primaryStage = (Stage)((Node)ae.getSource()).getScene().getWindow();
primaryStage.setScene(secondScene);
}
}
}
\ No newline at end of file
......@@ -2,21 +2,20 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.shape.Circle?>
<?import javafx.scene.layout.VBox?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="411.0" prefWidth="512.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="projekt.enigma.KenngruppeController">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="137.0" prefWidth="234.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="projekt.enigma.KenngruppeController">
<children>
<Label layoutX="81.0" layoutY="29.0" text="Bitte Kenngruppe eingeben!" AnchorPane.leftAnchor="81.0" AnchorPane.rightAnchor="70.0" AnchorPane.topAnchor="29.0" />
<HBox layoutX="107.0" layoutY="141.0" prefHeight="26.0" prefWidth="276.0" AnchorPane.leftAnchor="107.0" AnchorPane.rightAnchor="129.0" AnchorPane.topAnchor="141.0">
<VBox layoutX="13.0" layoutY="20.0" prefHeight="107.0" prefWidth="209.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="13.0" AnchorPane.rightAnchor="12.0" AnchorPane.topAnchor="20.0">
<children>
<Button fx:id="secondaryButton" onAction="#switchToPrimary" prefHeight="25.0" prefWidth="142.0" text="Kenngruppe bestätigen!" />
<Label prefHeight="17.0" prefWidth="159.0" text="Label" />
<Button mnemonicParsing="false" prefHeight="25.0" prefWidth="150.0" text="Button" />
<Label alignment="CENTER" contentDisplay="CENTER" prefHeight="17.0" prefWidth="208.0" text="Bitte Kenngruppe eingeben!" />
<Label prefHeight="62.0" prefWidth="209.0" />
<TextField fx:id="tfKenngruppe" />
<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!" />
</children>
</HBox>
<Circle fill="DODGERBLUE" layoutX="226.0" layoutY="267.0" radius="100.0" stroke="BLACK" strokeType="INSIDE" AnchorPane.leftAnchor="126.0" AnchorPane.rightAnchor="186.0" AnchorPane.topAnchor="167.0" />
<Button fx:id="secondaryButton" layoutX="40.0" layoutY="85.0" onAction="#switchToPrimary" prefHeight="25.0" prefWidth="241.0" text="Kenngruppe bestätigen!" />
</VBox>
</children>
</AnchorPane>
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