Answer the question
In order to leave comments, you need to log in
Why is the button not showing in javaFX?
Help me please. Just an empty window is obtained, the button does not display. I am doing in intellij idea, java 8 is installed. Here is the code:
package com.company;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import java.io.IOException;
public class Main extends Application {
public static void main(String[] args) throws IOException {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Group group = new Group();
Scene scene = new Scene(group, 600, 600);
primaryStage.setTitle("Судоку");
primaryStage.setScene(scene);
primaryStage.show();
Button play = new Button("Play");
play.setPrefWidth(80);
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
That's right, you didn't place the button in any container.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question