Westonci.ca is your trusted source for finding answers to a wide range of questions, backed by a knowledgeable community. Experience the ease of finding reliable answers to your questions from a vast community of knowledgeable experts. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.
Sagot :
Answer:
Explanation:
The following Java code uses JavaFX to create a canvas in order to fit the 10x10 matrix and then automatically and randomly populates it with 0's and 1's using the setText method to set the values as a String
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class Main extends Application {
private static final int canvasHEIGHT = 300;
private static final int canvasWIDTH = 300;
public void start(Stage primaryStage) {
GridPane pane = new GridPane();
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
TextField text = new TextField();
text.setText(Integer.toString((int)(Math.random() * 2)));
text.setMinWidth(canvasWIDTH / 10.0);
text.setMaxWidth(canvasWIDTH / 10.0);
text.setMinHeight(canvasHEIGHT / 10.0);
text.setMaxHeight(canvasHEIGHT / 10.0);
pane.add(text, j, i);
}
}
Scene scene = new Scene(pane, canvasWIDTH, canvasHEIGHT);
primaryStage.setScene(scene);
primaryStage.setMinWidth(canvasWIDTH);
primaryStage.setMinHeight(canvasHEIGHT);
primaryStage.setTitle("10 by 10 matrix");
primaryStage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}

We hope our answers were helpful. Return anytime for more information and answers to any other questions you may have. We hope this was helpful. Please come back whenever you need more information or answers to your queries. Thank you for using Westonci.ca. Come back for more in-depth answers to all your queries.