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

Merge branch 'master' into 'master'

1. GUI angepasst

See merge request alfatrainingkurse/java/enigma!112
parents 3a9710fe 6bc48541
No related branches found
No related tags found
No related merge requests found
......@@ -2,10 +2,9 @@ package projekt.enigma;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.*;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
......@@ -20,86 +19,80 @@ import java.io.IOException;
*/
public class App extends Application {
private static String kenngruppe;
private static GuiController gc;
private static int debug;
public static void main(String[] args) {
debug = 1;
launch(args);
}
public static int getDebug() {
return debug;
}
@Override
public void start(Stage primaryStage) throws IOException {
primaryStage.setTitle("Kenngruppenabfrage");
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();
layout1.getChildren().addAll(label1, l1, tfield, l2, button1);
Scene sceKenngruppe = new Scene(layout1, 234, 137);
FXMLLoader guiLoader = new FXMLLoader(App.class.getResource("gui.fxml"));
Scene sceApp = new Scene(guiLoader.load(), 962, 677);
tfield.setOnKeyPressed(e -> {
if (e.getCode() == KeyCode.ENTER) {
if (enter(tfield.getText())) {
gc = guiLoader.getController();
gc.setKenngruppe(tfield.getText());
primaryStage.setScene(sceApp);
} else {
tfield.setText("");
new Fehler().showErrorDialog("error", "Kenngruppe falsch",
"Regeln für die Kenngruppe: 4-8 Zeichen sowie nur Buchstaben von A-Z.");
}
}
});
button1.setOnAction(e -> {
if (enter(tfield.getText())) {
gc = guiLoader.getController();
gc.setKenngruppe(tfield.getText());
primaryStage.setScene(sceApp);
} else {
tfield.setText("");
new Fehler().showErrorDialog("error", "Kenngruppe falsch",
"Regeln für die Kenngruppe: 4-8 Zeichen sowie Buchstaben von A-Z.");
}
});
primaryStage.setScene(sceKenngruppe);
primaryStage.show();
}
private boolean enter(String kenngruppe) {
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
boolean result = true;
for (char c : kenngruppe.toUpperCase().toCharArray()) {
if (!alphabet.contains(String.valueOf(c))) {
result = false;
break;
}
}
if (kenngruppe.length() > 8 || kenngruppe.length() < 4) {
result = false;
}
return result;
}
private static GuiController gc;
private static int debug;
public static void main(String[] args) {
debug = 1;
launch(args);
}
public static int getDebug() {
return debug;
}
@Override
public void start(Stage primaryStage) throws IOException {
primaryStage.setTitle("Enigma");
Label lblEingbae = new Label("Bitte Kenngruppe eingeben!");
TextField tfEingabe = new TextField();
Button btnKenngruppe = new Button("Kenngruppe setzen!");
VBox layout = new VBox();
layout.setSpacing(30);
layout.setPadding(new Insets(30, 30, 30, 30));
btnKenngruppe.setMaxWidth(Double.MAX_VALUE);
layout.getChildren().addAll(lblEingbae, tfEingabe, btnKenngruppe);
Scene sceKenngruppe = new Scene(layout);
FXMLLoader guiLoader = new FXMLLoader(App.class.getResource("gui.fxml"));
Scene sceApp = new Scene(guiLoader.load(), 962, 677);
tfEingabe.setOnKeyPressed(e -> {
if (e.getCode() == KeyCode.ENTER) {
if (enter(tfEingabe.getText())) {
gc = guiLoader.getController();
gc.setKenngruppe(tfEingabe.getText());
primaryStage.setScene(sceApp);
} else {
tfEingabe.setText("");
new Fehler().showErrorDialog("error", "Kenngruppe falsch",
"Regeln für die Kenngruppe: 4-8 Zeichen sowie nur Buchstaben von A-Z.");
}
}
});
btnKenngruppe.setOnAction(e -> {
if (enter(tfEingabe.getText())) {
gc = guiLoader.getController();
gc.setKenngruppe(tfEingabe.getText());
primaryStage.setScene(sceApp);
} else {
tfEingabe.setText("");
new Fehler().showErrorDialog("error", "Kenngruppe falsch",
"Regeln für die Kenngruppe: 4-8 Zeichen sowie Buchstaben von A-Z.");
}
});
primaryStage.setScene(sceKenngruppe);
primaryStage.show();
}
private boolean enter(String kenngruppe) {
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
boolean result = true;
for (char c : kenngruppe.toUpperCase().toCharArray()) {
if (!alphabet.contains(String.valueOf(c))) {
result = false;
break;
}
}
if (kenngruppe.length() > 8 || kenngruppe.length() < 4) {
result = false;
}
return result;
}
// /**
// * TODO Dokumentieren
......
......@@ -671,52 +671,52 @@
</Label>
<Pane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="7">
<children>
<Pane fx:id="port0" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" />
<Pane fx:id="port0" disable="true" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" visible="false" />
</children>
</Pane>
<Pane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="7">
<children>
<Pane fx:id="port1" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" />
<Pane fx:id="port1" disable="true" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" visible="false" />
</children>
</Pane>
<Pane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="3" GridPane.rowIndex="7">
<children>
<Pane fx:id="port2" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" />
<Pane fx:id="port2" disable="true" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" visible="false" />
</children>
</Pane>
<Pane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="4" GridPane.rowIndex="7">
<children>
<Pane fx:id="port3" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" />
<Pane fx:id="port3" disable="true" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" visible="false" />
</children>
</Pane>
<Pane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="5" GridPane.rowIndex="7">
<children>
<Pane fx:id="port4" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" />
<Pane fx:id="port4" disable="true" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" visible="false" />
</children>
</Pane>
<Pane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="6" GridPane.rowIndex="7">
<children>
<Pane fx:id="port5" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" />
<Pane fx:id="port5" disable="true" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" visible="false" />
</children>
</Pane>
<Pane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="7" GridPane.rowIndex="7">
<children>
<Pane fx:id="port6" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" />
<Pane fx:id="port6" disable="true" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" visible="false" />
</children>
</Pane>
<Pane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="8" GridPane.rowIndex="7">
<children>
<Pane fx:id="port7" layoutY="-304.0" prefHeight="346.0" prefWidth="86.0" />
<Pane fx:id="port7" disable="true" layoutY="-304.0" prefHeight="346.0" prefWidth="86.0" visible="false" />
</children>
</Pane>
<Pane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="9" GridPane.rowIndex="7">
<children>
<Pane fx:id="port8" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" />
<Pane fx:id="port8" disable="true" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" visible="false" />
</children>
</Pane>
<Pane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="10" GridPane.rowIndex="7">
<children>
<Pane fx:id="port9" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" />
<Pane fx:id="port9" disable="true" layoutX="-3.0" layoutY="-303.0" prefHeight="346.0" prefWidth="86.0" visible="false" />
</children>
</Pane>
</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