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
Blind spots are those areas not reflected in your:
bulgar [2K]
The answer is C because your sideview and rearview mirrors are there specifically to check behind you, while the vanity mirror is not supposed to be used for the same purpose.
8 0
3 years ago
Read 2 more answers
What is meant by versatility in terms of features of computer?​
scoray [572]

Answer:

Versatility refers to the capability of a computer to perform different kinds of works with same accuracy and efficiency.

Explanation:

thank me later

3 0
2 years ago
Read 2 more answers
8.3 code practice edhesive PLEASE HELP AND HURRY
NemiM [27]

Answer:

numbers = '14 36 31 -2 11 -6'

nums = numbers.split(' ')

for i in range(0, len(nums)):

  nums[i] = int(nums[i])

print(nums)

8 0
2 years ago
Will give brainlyist
In-s [12.5K]

i think its the first sentence: Mobile devices have become the main source of communication for many people around the world

if im wrong im dum ;-;

6 0
2 years ago
Read 2 more answers
Which of the following describes the operating system
Marianna [84]

Answer:

Explanation:

you added no options

5 0
2 years ago
Other questions:
  • How do solar cells translate heat energy into mechanical energy
    13·1 answer
  • Enter a formula in cell b7 to calculate the average value of cells b2:b6
    13·1 answer
  • Your friend sends you a computer game. after installing the game on your computer, you realize that it plays very slowly. you kn
    14·1 answer
  • File Explorer contains ribbon tabs that can be used for various functions. Which ribbon tab provides options to open a new File
    11·1 answer
  • Does Windows 7 support secure boot in UEFI? Windows eight? Linux UBUNTU version 14?
    8·1 answer
  • The advantages of the dynamo
    15·1 answer
  • Discuss how a lack of infrastructure in poor communities could contribute to ill-health such as the Unrest looting.​
    9·1 answer
  • Why do you want to work for Rev?
    5·1 answer
  • When patel’s advertising co. decided to upgrade its computer network, many people were involved in the decision. In b2b buying s
    8·1 answer
  • Besides a soho router, which of these devices is a network printer most likely to be connected to? a. router b. server c. workst
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!