A beállítások ablak kontrollere és meghívása

This commit is contained in:
István Priskin 2021-12-06 14:56:30 +01:00
parent 15adbcef20
commit 9428de41b8
4 changed files with 66 additions and 5 deletions

View File

@ -6,7 +6,7 @@
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane prefHeight="400.0" prefWidth="400.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/16">
<AnchorPane prefHeight="400.0" prefWidth="400.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/16" fx:controller="hanoi.BeallitasController">
<children>
<Button fx:id="mentGomb" layoutX="135.0" layoutY="296.0" mnemonicParsing="false" onAction="#mentGombAction" text="Mentés és kilépés" />
<Label layoutX="45.0" layoutY="63.0" text="Alapértelmezett korongszám:" />

View File

@ -0,0 +1,49 @@
package hanoi;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Spinner;
import javafx.scene.control.SpinnerValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class BeallitasController {
@FXML
private ResourceBundle resources;
@FXML
private URL location;
@FXML
private Button mentGomb;
@FXML
private Spinner<Integer> defaultKszamSpin;
@FXML
private Spinner<Integer> stepMaxSpin;
@FXML
void mentGombAction(ActionEvent event) {
}
@FXML
void initialize() {
assert mentGomb != null : "fx:id=\"mentGomb\" was not injected: check your FXML file 'Beallitas.fxml'.";
assert defaultKszamSpin != null : "fx:id=\"defaultKszamSpin\" was not injected: check your FXML file 'Beallitas.fxml'.";
assert stepMaxSpin != null : "fx:id=\"stepMaxSpin\" was not injected: check your FXML file 'Beallitas.fxml'.";
SpinnerValueFactory<Integer> valueFactory1 = new SpinnerValueFactory.IntegerSpinnerValueFactory(4, 10, 4);
defaultKszamSpin.setValueFactory(valueFactory1);
SpinnerValueFactory<Integer> valueFactory2 = new SpinnerValueFactory.IntegerSpinnerValueFactory(40, 300, 100);
stepMaxSpin.setValueFactory(valueFactory2);
}
}

View File

@ -39,9 +39,6 @@ public class FoablakController {
FXMLLoader fl = new FXMLLoader(getClass().getResource("hanoi_form2.fxml"));
VBox root = (VBox)fl.load();
Scene sc = new Scene(root);
Node n = (Node) event.getSource();
Stage st = (Stage) n.getScene().getWindow();

View File

@ -1,6 +1,7 @@
package hanoi;
import java.io.Closeable;
import java.io.IOException;
import java.net.URL;
import java.util.Optional;
import java.util.ResourceBundle;
@ -8,6 +9,8 @@ import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
@ -72,7 +75,19 @@ public class HanoiFormController {
@FXML
void beallKattintas(ActionEvent event) {
FXMLLoader fl = new FXMLLoader(getClass().getResource("Beallitas.fxml"));
AnchorPane root;
try {
root = (AnchorPane)fl.load();
Scene sc = new Scene(root);
Stage st = (Stage) jatekTerulet.getScene().getWindow();
st.setScene(sc);
st.show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@FXML