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
DiKsa [7]
3 years ago
6

Using javaFX components

Computers and Technology
1 answer:
AysviL [449]3 years ago
3 0

Answer:

package colorchanger;

import javafx.application.Application;

import javafx.geometry.Insets;

import javafx.scene.Scene;

import javafx.scene.control.RadioButton;

import javafx.scene.control.ToggleGroup;

import javafx.scene.layout.HBox;

import javafx.stage.Stage;

public class ColorChanger extends Application {

   @Override

   public void start(Stage primaryStage) {

       //Create the two radio buttons

       RadioButton radio1 = new RadioButton("White");

       RadioButton radio2 = new RadioButton("Red");

       //Create a toggle group for the buttons

       ToggleGroup tg = new ToggleGroup();

       //Add the two buttons to the toggle group

       radio1.setToggleGroup(tg);

       radio2.setToggleGroup(tg);

       //Create an HBox to hold the two radio buttons

       HBox hb = new HBox();

       hb.getChildren().addAll(radio1, radio2);

       hb.setPadding(new Insets(10));

       hb.setSpacing(10);

       hb.setPrefSize(30, 15);

       //Set action for the two buttons

       //When the radio1 button is clicked, the background color of the horizontal box (HBox) changes to white

       radio1.setOnAction(e -> {

           hb.setStyle("-fx-background-color:white");

       });

       //When the radio2 button is clicked, the background color of the horizontal box (HBox) changes to red

       radio2.setOnAction(e -> {

           hb.setStyle("-fx-background-color:red");

       });

       //Create a scene to hold the HBox

       Scene scene = new Scene(hb, 300, 250);

       //Create a primary stage to act as window

       primaryStage.setTitle("Color Changer");

       primaryStage.setScene(scene);

       primaryStage.show();

   }

   /**

    * @param args the command line arguments

    */

   public static void main(String[] args) {

       launch(args);

   }

}

Explanation:

Go through the comments in the code for explanation.

The source code file has also been attached to this response.

Hope this helps!

Download java
You might be interested in
How many pieces are there in a normal laptop??? Good luck and solve carefully
polet [3.4K]

What do you mean pieces? Like Laptop components? If so then motherboard,ram,cpu, and psu for a basic laptop so 4 I guess (5 if you want to include a gpu).

4 0
3 years ago
A user reports network resources can no longer be accessed. The PC reports a link but will only accept static IP addresses. The
Aloiza [94]

Answer: is this a real question but I think it would be Ip address hope this helps :)))

Explanation:

3 0
3 years ago
Please select the word from the list that best fits the definition
Troyanec [42]

Answer

Linguistics

Explanation:

linguistics can be defined as scientific study of language and its structure, including the study of grammar, syntax, and phonetics.

there are some  Specific branches of linguistics  and that include computational linguistics, comparative linguistics, and structural linguistics.

study material into songs can also be defined as a linguistic hence linguistic is the correct option for you question

6 0
4 years ago
Read 2 more answers
Is the Internet dangerous?
VARVARA [1.3K]

Many people would answer this in many different ways. In my personal opinion, it's a yes. It's a yes because it makes it easier for people to track you down (finding your iep) and it's easy for someone to take your identity. It's also dangerous for children and teens (even young adults) because there are many people wanting them, and wanting to meet them in public and things like that. I hope I answered your question! (:

8 0
3 years ago
Read 2 more answers
All changes
Vsevolod [243]

You should get up and move every 30 minutes

Hope  this helps

-scav

7 0
3 years ago
Other questions:
  • _____ is an information-analysis tool that involves the automated discovery of patterns and relationships in a data warehouse.
    12·1 answer
  • A new company is upgrading a media workstation. The computer will be predominantly used for graphic intensive presentations, sli
    13·1 answer
  • Consider the partially-filled array named a. What does the following loop do? (cin is a Scanner object)int[] a = {1, 3, 7, 0, 0,
    6·1 answer
  • \Read the sentence.
    12·1 answer
  • What should you rely on to determine when to change your oil? a. Oil color b. 6,000 miles since the last oil change c. Owners ma
    7·1 answer
  • a paragraph is a segment of text with the same format that begins when you press the enter key and ends when you press enter key
    6·2 answers
  • Betty set up an account on a popular social networking website. she wants to know whether the privacy policy is effective for he
    14·1 answer
  • I live in Alabama and I’m ab to leave to go on a 3 week trip to France and I’m wondering how I can get LTE for my IPhone 6s Plus
    15·2 answers
  • HELPPP PLEASE <br><br> Html can be used to create complicated mobile applications <br> True or false
    10·1 answer
  • Ten ways ict has helped in social development
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!