Question

JavaFX! Just need to fill several lanes of code please!!!

CSE205 OOP and Data Structure Quiz #15 Last Name (print) First Name (print) Write a JavaFX GUI application program that simul

CSE205 00P and Data Structure Quiz #15 First Name (print) Last Name (print): //Create a KeyFrame object that increase the tim

CSE205 OOP and Data Structure Quiz #15 Last Name (print) First Name (print) Write a JavaFX GUI application program that simulates a timer. The timer should show "count: the beginning and increase the number by 1 in every one second, and so on. o" at .3 A Timer - × A Timer Count: 0 Count: 1 (B) After 1 second, the GUI Window (A) Initial GUI Window According to the description, finish the following program import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.StackPane; import javafx.scene.control.Label; import javafx.scene.text.Font: import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.util.Duration; import javafx.event.ActionEvent; import javafx.event.EventHandler public class TimerQuiz extends Application private Label label; private int number; private Timeline timer; public void start (Stage primaryStage) number = 0; //initialize the label Label.setFont (new Font ("Arial", 30)): StackPane rootPane new StackPane(): //add the label inside the root Pane
CSE205 00P and Data Structure Quiz #15 First Name (print) Last Name (print): //Create a KeyFrame object that increase the timer every 1 second KeyFrame kf- //create a Timeline object called 、tiner, from above KeyFrame object //Set timer's cycle count to indefinite //start the timer // Create a scene and place the root Pane in the stage scene scene = new scene (rootPane , 220, 100); primaryStage.setTitle("A Timer"):/ Set the stage title primaryStage.setScene (scene): / Place the scee in the stage primarystage.show);7/ Display the stage //Handler class private class TimerHandler implements public void handle (ActionEvent event) //need to increase the number by 1 //change the label's text //The main method is only needed for the IDE with limited JavaFX support public static void main(String[] args) launch (args): //end of TimerQuiz class
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The Bold Lines are the answers for fill in the blanks

Code :

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package counter;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.util.Duration;

/**
*
* @author rohit
*/
public class TimerQuiz extends Application {
  
private Label label;
private int number;
private Timeline timer;
public void start(Stage primaryStage) {
number=0;
label = new Label();
label.setText("Count: "+number);

label.setFont(new Font("Arial",30));
StackPane root = new StackPane();
root.getChildren().add(label);
  
  
KeyFrame kf= new KeyFrame (Duration.seconds(1),new TimerHandler());
timer = new Timeline();
timer.getKeyFrames().add(kf);
timer.setCycleCount(timer.INDEFINITE);
timer.playFromStart();

  
Scene scene = new Scene(root, 220, 100);
primaryStage.setTitle("A Timer");
primaryStage.setScene(scene);
primaryStage.show();
}
  
private class TimerHandler implements EventHandler{
public void handle (Event e){
number+=1;
label.setText("Count: "+number);
}


}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
  
}

OUTPUT :

A Timer- Count: 0

A Timer- Count: 16

Alimer- Count: 27

Add a comment
Know the answer?
Add Answer to:
JavaFX! Just need to fill several lanes of code please!!! CSE205 OOP and Data Structure Quiz #15 Last Name (print) First Name (print) Write a JavaFX GUI application program that simulates a timer. T...
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
  • For this question you will need to complete the methods to create a JavaFX GUI application...

    For this question you will need to complete the methods to create a JavaFX GUI application that implements two String analysis algorithms. Each algorithm is activated when its associated button is pressed. They both take their input from the text typed by the user in a TextField and they both display their output via a Text component at the bottom of the GUI, which is initialized to “Choose a string methods as indicated in the partially completed class shown after...

  • JavaFX programming (Not Javascript) Using the code from BallPane.java and BounceBallControl.java create a "Pong for One"...

    JavaFX programming (Not Javascript) Using the code from BallPane.java and BounceBallControl.java create a "Pong for One" game - a rectangular paddle moves back and forth via mouse drag along the bottom of the pane; the bottom of the paddle should be about 1/2 the diameter of the ball off the bottom. If the ball connects with the paddle, then it bounces at a 90 degree angle back into the pane space. If the ball misses the paddle, then the score...

  • Modify the JavaFX TipCalculator application program to allow the user to enter the number of persons...

    Modify the JavaFX TipCalculator application program to allow the user to enter the number of persons in the party through a text field. Calculate and display the amount owed by each person in the party if the bill is to be split evenly among the party members. /////////// TipCalculatorController.java: import java.math.BigDecimal; import java.math.RoundingMode; import java.text.NumberFormat; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.control.Slider; import javafx.scene.control.TextField; public class TipCalculatorController { // formatters for currency and percentages private...

  • //No JPanel please: Write a javafx application that displays an image and //plays a sound effect...

    //No JPanel please: Write a javafx application that displays an image and //plays a sound effect with each mouse click. Rotate through four images and //five sound effects, so the image/sound effect pairing is different each time. //What my problem is on is actually getting the pictures to switch. The x variable //works perfect for the sound change but I am unsure what to do with y for the //image change. Also I dont know if I should put this...

  • I need to make javafx GUI application called Email that implements a prototype user interface for...

    I need to make javafx GUI application called Email that implements a prototype user interface for composing email message. The application should have labelled text fields for To, cc,bcc ,subject line, one for message body and button lebelled Send. When we click Send button, the program should print contents of all fields to standard output using println() statement. I am attaching photos of Email.java and EmailPane.java, I need to make it as per these classes CylinderSta.. Cylinder java MultiCylind.. ....

  • ***Please keep given code intact*** Write a JavaFX application that displays a label and a Button...

    ***Please keep given code intact*** Write a JavaFX application that displays a label and a Button to a frame in the FXBookQuote2 program. When the user clicks the button, display the title of the book that contains the opening sentence or two from your favorite book in the label. FXBookQuote2.java /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the...

  • Answer questions 1-20 about creating GUI applications with JavaFX 1. A tree-like data structure that contains...

    Answer questions 1-20 about creating GUI applications with JavaFX 1. A tree-like data structure that contains the components of a JavaFX GUI is called a: a. directory tree b. node tree c.node graph d. scene graph 2. A node in a scene graph that contains other nodes is called a: a. root node b. branch node c. leaf node d. terminal node 3. A node in a scene graph that has no children is called a: a. root node b....

  • Use Kilometer Converter application code to write Temperature Converter application to convert degrees Fahrenheit into degrees...

    Use Kilometer Converter application code to write Temperature Converter application to convert degrees Fahrenheit into degrees Celsius ((F - 32)*5/9). It needs to be JavaFX 1 import javafx.application. Application; 2 import javafx.stage. Stage; 3 import javafx.scene. Scene; 4 import javafx.scene.layout.HBox; 5 import javafx.scene.layout. VBox; 6 import javafx.geometry.Pos; 7 import javafx.geometry.Insets; 8 import javafx.scene.control.Label; 9 import javafx.scene.control. TextField; 10 import javafx.scene.control.Button; 11 import javafx.event. EventHandler; 12 import javafx.event. ActionEvent; 13 14 ** 15 * Kilometer Converter application 16 17 18 public...

  • You may adjust the code as you want. Thank you! CODING HERE: import javafx.application.Application; import javafx.event.*;...

    You may adjust the code as you want. Thank you! CODING HERE: import javafx.application.Application; import javafx.event.*; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.stage.*; import javafx.geometry.*; public class OrderSystem extends Application implements EventHandler<ActionEvent> { // Attributes for GUI private Stage stage; // The entire window, including title bar and borders private Scene scene; // Interior of window private BorderPane layout; // Add four labels private Label itemLabel = new Label("Item Name:"); private Label numberLabel = new Label("Number:"); private Label costLabel...

  • ******Java Programming Hi guys, I really need you help. I created a code for my java...

    ******Java Programming Hi guys, I really need you help. I created a code for my java course, but it keep giving me error messages. Majority of my code is fine but some keep display error on my console. I was hoping someone could pin points the problem. .There are three classes with the testCenter class being the main class. In the following is the assignment, and the bottom is my code. Please help! Assignment: Concepts: GUI User Design Graphics Deployment...

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