Discover the answers you need at Westonci.ca, a dynamic Q&A platform where knowledge is shared freely by a community of experts. Connect with a community of experts ready to help you find solutions to your questions quickly and accurately. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.
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);
}
}
Thank you for visiting our platform. We hope you found the answers you were looking for. Come back anytime you need more information. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. We're glad you chose Westonci.ca. Revisit us for updated answers from our knowledgeable team.