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]
2 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]2 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
Hey! I was recommended a site “9anime” the other day. All’s been going well but I accidentally taped on a new dub settingZ somet
Studentka2010 [4]

Answer:

yep defiantly virus

Explanation:

8 0
2 years ago
Read 2 more answers
Ms. Osteen gives her class an assignment to insert background color that gradually changes from blue to green. To accomplish thi
irina1246 [14]

Answer:

C

Explanation:

7 0
3 years ago
Problem statement: Using loop, write a program that will ask the user to enter a character for left or right. Then, the user wil
zvonat [6]
Define variables
left is l
right is r

Ask input
left or right

Ask input value

Equate l or r to the input value

Show ladder with steps equal to input value and in the side of input variable
7 0
3 years ago
You configured the IP address and DNS name of a new internal web server named WEB3. Your first test from a web browser on your w
bonufazy [111]

Answer:

I would reset the Domain Name System (DNS)

Explanation:

One factor that could lead to the "Site Cannot Be Reached" error is DNS "poisoning". Another is invalid DNS cache. Both can be caused by an attack on the system by people trying to spoof the system. Spoofing ensures that even when the right address is entered, it leads one to another web address.

One way to quickly reset the DNS is to run ipconfig /flushdns

This helps to clear the DNS cache.

Once the DNS cache has been successfully flushed, the system returns a confirmatory message that reads “flushed the DNS resolver cache”.

The systems administrator can now proceed to reconfigure the IP address(es)

Cheers

3 0
3 years ago
Different methods of developing useful information from large data bases are dealt with under
oee [108]

Answer:

The answer to this question is option "d".

Explanation:

In this question, the answer is data mining. Because Data mining is a technique that finds a piece of new information in a lot of the data. In the data mining collecting information from data is hopefully both new and useful. Data mining help us to discover new patterns and relationship in data to help make better decisions. It is used everywhere like Television and radio, Banking, Retail, and business. That's why data mining is useful.

4 0
3 years ago
Other questions:
  • Which is an example of an input device?
    15·2 answers
  • Write a new program called Lab7D that will read strings from a text file and turn them into "encrypted code". Create a bool func
    14·1 answer
  • In chapter 3, we discussed syntax and semantics, in general there are two types of grammars for programming languages, regular a
    14·1 answer
  • The order of precedence is very important when building formulas in Excel. Which of the following formulas will produce 778 as t
    11·1 answer
  • Conclusion for primary memory
    15·1 answer
  • Which category does this fall in identity theft​
    6·1 answer
  • Which of the following is input devices? (a)Scanner (b) Keyboard (c) Both a and b (d) Plotter​
    5·1 answer
  • You want to use the randrange() method. Which line will allow you to enter the following code in IDLE?
    12·2 answers
  • MSWord is a popular___________ program.​
    7·2 answers
  • ____ the most popular word processing applications software<br><br>​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!