Answer the question
In order to leave comments, you need to log in
JavaFX how to make the selected level from the dropdown menu affect the button?
Hello. I have a play button that, when pressed, generates a table (this calls a method into which I pass the desired table size) and a menu with difficulty levels. How can I make the selected level in the menu affect the size of the generated table? Simply put, how to link a menu and a button?
@Override
public void start(Stage stage) throws Exception {
ObservableList<String> parameters = FXCollections.observableArrayList("9 x 9", "16 x 16", "25 x 25");
ComboBox<String> par = new ComboBox<String>(parameters);
par.setValue("9 x 9");
Button play = new Button("Начать игру");
VBox root = new VBox(par, play);
Scene scene = new Scene(root, 600, 600);
stage.setScene(scene);
stage.setTitle("Судоку");
stage.show();
play.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
TableFactory tablefactory = new TableFactory();
int[][] board = tablefactory.generateBoard(9); // Вот сюда я передаю нужный размер таблицы
tablefactory.printTheBoard(board);
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question