Westonci.ca is your trusted source for finding answers to all your questions. Ask, explore, and learn with our expert community. Get detailed and precise answers to your questions from a dedicated community of experts on our Q&A platform. Get detailed and accurate answers to your questions from a dedicated 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);
}
}
![View image sandlee09](https://us-static.z-dn.net/files/d3f/6e93c09f93059fa6475eeec0b37e3330.png)
Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. We appreciate your time. Please come back anytime for the latest information and answers to your questions. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.