Question

Need Java Code for this Algorithm Workbench Textbook Question: Assume scene is the name of a...

Need Java Code for this Algorithm Workbench Textbook Question: Assume scene is the name of a Scene object, and styles.css is the name of a CSS stylesheet. Write the statement that applies the styles.css stylesheet to scene. Ratings and comments given to correct answer, Thanks!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the solution:

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Text;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

public class cssStyleInJavaFX extends Application {
   @Override
   public void start(Stage stage) {    
      //login label
      Text lblLoginName = new Text("Login ID:");     
    
      // password label
      Text lblPassword = new Text("Password:");
     
      //loginid text field     
      TextField txtLoginId = new TextField();     
    
      //password text field     
      PasswordField txtPassword = new PasswordField();
     
      //Button submit and
      Button submit = new Button("Login");
    
      //Creating a Grid Pane
      GridPane gridPane = new GridPane();  
    
      //Setting size for the pane
      gridPane.setMinSize(400, 200);
    
      //Set the padding
      gridPane.setPadding(new Insets(10, 10, 10, 10));
    
      //Set the vertical and horizontal gaps between the columns
      gridPane.setVgap(10);
      gridPane.setHgap(10);
    
      //Setting the Grid alignment
      gridPane.setAlignment(Pos.CENTER);
     
      //Arranging all the nodes in the grid
      gridPane.add(lblLoginName, 0, 0);
      gridPane.add(txtLoginId, 1, 0);
      gridPane.add(lblPassword, 0, 1);
      gridPane.add(txtPassword, 1, 1);
      gridPane.add(submit, 1, 2);
     
      //Styling button
      submit.setStyle("-fx-background-color: orange; -fx-text-fill: white;");
      //Styling label Login name
      lblLoginName.setStyle("-fx-font: normal bold 16px 'serif' ");
      //Styling label password
      lblPassword.setStyle("-fx-font: normal bold 16px 'serif' ");
      gridPane.setStyle("-fx-background-color: lightblue;");
     
      // Create a scene object
      Scene scene = new Scene(gridPane);
     
      // Set title to the Stage
      stage.setTitle("CSS Styling");
       
      // Add scene to the stage
      stage.setScene(scene);
    
      //Display the contents of the stage
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}

output:

Add a comment
Know the answer?
Add Answer to:
Need Java Code for this Algorithm Workbench Textbook Question: Assume scene is the name of a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need Java Code for this Algorithm Workbench question: Suppose we have a stylesheet named styles.css, and...

    Need Java Code for this Algorithm Workbench question: Suppose we have a stylesheet named styles.css, and in our Java code the scene variable references the Scene object. Write a statement to add the stylesheet to the scene. Ratings will be given, and comments. Thanks

  • write in java 4. [10 pts]Assume primayStage references the Stage object, and scene references your Scene...

    write in java 4. [10 pts]Assume primayStage references the Stage object, and scene references your Scene object. Write a statement that adds the scene to the stage.

  • Need JAVA code for the following question. I am using Eclipse IDE. Ratings will be given...

    Need JAVA code for the following question. I am using Eclipse IDE. Ratings will be given to the correct answer. Send the code and screenshots of the program running. 2.) Name Formatter Create a JavaFX application that lets the user enter the following pieces of data: - The user's first name - The user's middle name - The user's last name - The user's preferred title (Mr., Mrs., Ms., Dr., and so on.) Assume the user has entered the following...

  • I need help with this assignment. Please include comments throughout the program. Thanks Develop an algorithm...

    I need help with this assignment. Please include comments throughout the program. Thanks Develop an algorithm and write the program in java for a simple game of guessing at a secret five-digit code. When the user enters a guess at the code, the program returns two values: the number of digits in the guess that are in the correct position and the sum of those digits. For example, if the secret code is 13720, and the user guesses 83521, the...

  • Write a java code to solve the following question using the backtracking algorithm. Given a set...

    Write a java code to solve the following question using the backtracking algorithm. Given a set of distinct integers, return all possible subsets. input: new int[] {1,2,3} output: [], [3], [2], [2,3], [1], [1,3], [1,2], [1,2,3] What to submit: 1. Your source code in a text document (15pts), 2. A screen copy showing you can run the code and the result of running the code (5 pts). 3. What is the performance of your algorithm (5 pts), give the answer,...

  • In JAVA Algorithm Workbench 1. Write the first line of the definition for a Poodle class....

    In JAVA Algorithm Workbench 1. Write the first line of the definition for a Poodle class. The class should extend the Dog class. 2. Look at the following code, which is the first line of a class definition: public class Tiger extends Felis In what order will the class constructors execute? 3. Write the statement that calls a superclass constructor and passes the arguments x, y, and z. 4. A superclass has the following method: public void setValue(int v) value...

  • I need help with the following question please in JAVA code. Hash code is used to...

    I need help with the following question please in JAVA code. Hash code is used to “encode” general keys into integers. One approach of creating a hash code is to use Java's hashCode() method. The hashCode() method is implemented in the Object class and therefore each class in Java inherits it. The hash code provides a numeric representation of an object (this is somewhat similar to the toString method that gives a text representation of an object). Write a program...

  • I need this in Net beans and not Python. Part 1 - Pseudo-code Design and write...

    I need this in Net beans and not Python. Part 1 - Pseudo-code Design and write the pseudo-code for the following Problem Statement. Problem Statement A company gives its employees an that will provide one of 3 results based on the following ranges of scores: Score Message on Report 90-100 Special Commendation 70-89 Pass Below 70 Fail Design a single If-Then-Else structure using pseudo-code which displays one of these messages based a score input by a user. Be sure your...

  • need Algorithm and java code, please don't post only one!! Define a class called Counter. An...

    need Algorithm and java code, please don't post only one!! Define a class called Counter. An object of this class is used to count things so it records a count that is a non-negative whole number. Include methods to set the counter to 0, to increase the counter by 1, and to decrease the counter by 1. Be sure that no method allows the value of the counter to become negative. Also include an accessor method that returns the current...

  • PLEASE UPLOAD or Write a simple PSEUDO CODE AND JAVA CODE for this program WITH COMMENTS...

    PLEASE UPLOAD or Write a simple PSEUDO CODE AND JAVA CODE for this program WITH COMMENTS IN BOTH TELLING WHAT EACH PART DOES. (I NEED BOTH CODES NOT JUST ONE OR THE OTHER) Problem Statement A golf club has a small tournament consisting of five golfers every weekend. The club president has asked you to design a program that does the following: Reads player’s names and their scores from the keyboard for each of the five golfers and simulates writing...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT