Question
Task1: Properties for Nodes Add NodeStyleRotateDemo.java to your project. Run the program. Modify the code to rotate the button 45 degrees counterclockwise. Run the program.
Task1: Properties for Nodes
Add NodeStyleRotateDemo.java to your project. Run the program.
Modify the code to rotate the button 45 degrees counterclockwise. Run the program.
Modify the code to set the text color for the button to red. You will need to refer to the online reference of JavaFX Node properties:
Read through the catalogue and find the appropriate subject that might be related with seting text color. See if you can find the CSS syntax by yourself.
Use the contains(double x, double y) method to check if pixel(0,0) is inside the button. Check if pixel (200, 250) is inside the pane and if pixel (201, 250) is inside the pane. You can add if-else clause at the end of the program to print out YES or NO as the checking results.
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; import javafx.scene.layout.StackPane;
public class NodeStyleRotateDemo extends Application { @Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a scene and place a button in the scene StackPane pane = new StackPane(); Button btOK = new Button("OK"); btOK.setStyle("-fx-border-color: blue;"); pane.getChildren().add(btOK); pane.setRotate(45); pane.setStyle( "-fx-border-color: red; -fx-background-color: lightgray;"); Scene scene = new Scene(pane, 200, 250); primaryStage.setTitle("NodeStyleRotateDemo"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage
} /** * 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); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started