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 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...

  • 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...

  • USE JAVA, PYTHON OR C TO WRITE AN ALGORITHM FOR THIS EXERCISE: . Chocolate bar puzzle...

    USE JAVA, PYTHON OR C TO WRITE AN ALGORITHM FOR THIS EXERCISE: . Chocolate bar puzzle Given an n × m chocolate bar, you need to break it into nm 1 × 1 pieces. You can break a bar only in a straight line, and only one bar can be broken at a time. Design an algorithm that solves the problem with the minimum number of bar breaks. What is this minimum number? Justify your answer by using the properties...

  • .Need code for my java class !! Write a simple java program that uses loops. You...

    .Need code for my java class !! Write a simple java program that uses loops. You may use ‘WHILE’ or ‘FOR’ or ‘DO-WHILE’ – you decide. The program should use a loop to compute the semester average for up to 5 students. In the loop the user will ask for a student name and their 3 test scores and add them up and divide the total by 3 giving the semester average. You will print out the student name and...

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
ADVERTISEMENT