Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Simple JavaFX homework Hi, I\'m working on a test prgram that needs to implement

ID: 3770388 • Letter: S

Question

Simple JavaFX homework

Hi, I'm working on a test prgram that needs to implement all of these. not sure how to do it.

They all need to be done with JavaFX

(a) Change the color scroll bars from a horizontal orientation along the bottom
to a vertical orientation along the right, with labels “R”, “G”, “B”, and “O”
under their respective scroll bars.
(b) Add the ability to change the text via a password field.
(c) Add the ability to change the location of the text via mouse click.
(d) Add the ability to change the font size (12, 24, 48) via radio buttons.
(e) Add the ability to change the text to uppercase via the up-arrow key, and
back to normal via the down-arrow key.

Here's the code it gave me to start with:

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollBar;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Test3 extends Application {
private double paneWidth = 480;
private double paneHeight = 250;
private Text text = new Text("Show Colors");
private ScrollBar scbRed = new ScrollBar();
private ScrollBar scbGreen = new ScrollBar();
private ScrollBar scbBlue = new ScrollBar();
private ScrollBar scbOpacity = new ScrollBar();
  
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
BorderPane pane = new BorderPane();
  
GridPane gridPane = new GridPane();
gridPane.add(new Label("Red"), 0, 0);
gridPane.add(new Label("Green"), 0, 1);
gridPane.add(new Label("Blue"), 0, 2);
gridPane.add(new Label("Opacity"), 0, 3);
gridPane.add(scbRed, 1, 0);
gridPane.add(scbGreen, 1, 1);
gridPane.add(scbBlue, 1, 2);
gridPane.add(scbOpacity, 1, 3);
  
pane.setBottom(gridPane);
pane.setCenter(text);
gridPane.setAlignment(Pos.CENTER);
gridPane.setVgap(5);
gridPane.setHgap(5);

// Create a scene and place it in the stage
Scene scene = new Scene(pane, paneWidth, paneHeight);
primaryStage.setTitle("Exercise16_17"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage

scbRed.valueProperty().addListener(ov -> {
updateColor();
});
scbGreen.valueProperty().addListener(ov -> {
updateColor();
});
scbBlue.valueProperty().addListener(ov -> {
updateColor();
});
scbOpacity.valueProperty().addListener(ov -> {
updateColor();
});
}

private void updateColor() {
double red = scbRed.getValue() / scbRed.getMax();
double green = scbGreen.getValue() / scbGreen.getMax();
double blue = scbBlue.getValue() / scbBlue.getMax();
double opacity = scbOpacity.getValue() / scbOpacity.getMax();
text.setFill(Color.color(red, green, blue, opacity));
}
/**
* The main method is only needed for the IDE with limited
* JavaFX support. Not needed for running from the command line.
*/
public static void main(String[] args) {
launch(args);
}
}

Explanation / Answer

Add the ability to change the text to uppercase via the up-arrow key, and
back to normal via the down-arrow key.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote