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
What are the steps involved in accepting all the changes in a document?
Makovka662 [10]

To accept all the changes in a document click Accept All.

4 0
3 years ago
Read 2 more answers
Why is the Singleton pattern commonly referred to as an “anti-pattern”?
snow_lady [41]

Answer:

Singleton pattern is the pattern for design that is build using the global variables which creates a lot of drawback in the designing. Singleton pattern are considered with the global variable and thus cannot be bound into single unit which complexes the components in design.

They have a loose coupled variables in design and also does not show the property of the multi-threading .These feature are responsible for the decrement in the performance and thus are not highly preferred choice for the pattern.So, it is known as the "anti- pattern".

3 0
3 years ago
According to the lecture, in communication, men tend to value ____________.
Andru [333]

Answer:

respect?

Explanation:

8 0
3 years ago
What is a feature of audio editing software
soldier1979 [14.2K]

I am pretty sure that Audio editing software is software which allows editing and generating of audio data. Audio editing software can be implemented completely or partly as library, as computer application, as Web application or as a loadable kernel module.

please mark brainliest

6 0
3 years ago
How do I translate my Flowchart into Psuedocode?
harkovskaia [24]

Answer:

Step 1

Open the flowchart and locate the startinglocation on the chart.

Step 2

Write the pseudocode that is equivalent to the rectangular process boxes in your diagram.

Step 3

Write the pseudocode for the diamond-shaped decision boxes in your diagram.

Step 4

Write the pseudocode for the end terminator of the flowchart.

Combine all of your converted statements above and you have a flowchart that has been converted to pseudocode.

8 0
3 years ago
Other questions:
  • Which of the following Statements accurately describes the legality of telemarketing
    12·1 answer
  • When you send an email how many computers does it go to
    12·1 answer
  • Which amendment to the Constitution ended slavery in the United States?
    8·1 answer
  • The ____ tag is used to bring an image into a website. <br> (I need the blank for tag)
    13·2 answers
  • Which peripheral device is used to record sound?
    14·2 answers
  • Can someone please type a code that makes a house in python and turtle graphics i need help
    9·1 answer
  • How do you enter the decimal 73 into the computer?
    11·1 answer
  • What role do play in medicine ​
    11·1 answer
  • HOW TO DISCONNECT A MONITOR FROM A SYSTEM UNIT
    6·1 answer
  • 2.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!