1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sertanlavr [38]
3 years ago
5

How would you write this using Java: Use a TextField's setText method to set value 0 or 1 as a string?

Computers and Technology
1 answer:
katrin [286]3 years ago
3 0

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);

   }

}

You might be interested in
If the code for CAT is ECV what is the code for DOG? *
masha68 [24]
This seems to be a ROT2 Ceasar cipher. Replace each letter with a letter two places futher in the alphabet. Do the same with DOG and get <span>FQI.</span>
3 0
3 years ago
Read 2 more answers
What's your fav show?
mezya [45]

Answer:

<h3>ITS DEPENDS IF I'M INTERESTED</h3>

Explanation:

HBU?^_________^

6 0
3 years ago
Read 2 more answers
Which of the following statements is used to terminate the program when closing the frame?
blondinia [14]

Answer:

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

Explanation:

JFrame is the swing class that is used to display a frame object. The JFrame display contains an X button on the top right position which is used to turn off the display of the frame. However if we want to terminate the program on pressing the X button, we need to update the DefaultCloseOperation for the frame. JFrame provides a method ''setDefaultCloseOperation' for this purpose. When this method is called with the argument JFrame.EXIT_ON_CLOSE , it will cause the program to exit when the close button is pressed.

4 0
4 years ago
What are the two types of programming languages?
ddd [48]

Answer:

High level language.

Low level language

Explanation:

please give brainliest

3 0
3 years ago
Assume that the variables gpa, deansList and studentName, have been declared and initialized . Write a statement that both adds
Alborosie

Answer:

Following are the statement which is given below:

if (gpa > 3.5)  // check the condition if gpa exceeds 3.5.

{

deansList++;  // increment of 1 in the deansList variable

cout << studentName;  // display the studentName,  

}

Explanation:

The description of the statement

  • In the if statement we check the condition of "gpa" .if  "gpa"  is greater then 3.5 then it executed the statement inside the if block otherwise nothing will be executed.
  • if control moves to the if part it adds to 1 to the deansList.
  • Finally, display the value of studentName.
3 0
3 years ago
Other questions:
  • A small company connects data acquisition equipment to the serial port of a computer. The equipment user has reported that not a
    8·1 answer
  • If the Update Automatically option is chosen in the Date and Time dialog box, _____. the date will automatically change each tim
    7·1 answer
  • Some careers emerge to address the environmental impact human behaviors and processes might be having on our planet. True False
    9·2 answers
  • Using gettimeofday(), determine how long it takes to start a new process with fork(). Include a histogram or other distribution
    9·1 answer
  • Megan says she never needs to look at the Transport Layer when she is searching for what went wrong with the network she support
    15·2 answers
  • For this scenario related to turtle drawing, indicate whether it is better to write a loop or a function (or a set of functions)
    13·1 answer
  • Why are various creative works split up into different types under copyright law?
    9·1 answer
  • Instructions
    15·1 answer
  • Who knows songs that are sad,happy,excited, and calm
    10·1 answer
  • Which of the following is a document view you can select using Button on the status bar?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!