
Please check if there is any issue with my code and please upload a screenshot of result when it is working.
Please add proper comments as well.
// need for using JavaFx
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.geometry.*;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class Main extends Application
{
atOverride
public void start(Stage primaryStage) throws Exception
{
primaryStage.setTitle("Tip Calculator"); //setting the title
GridPane rootNode = new GridPane();
rootNode.setPadding(new Insets(15));
Scene myScene = new Scene(rootNode, 300, 200); //create a scene
rootNode.add(new Label("Amount:"), 0, 0);
TextField firstValue = new TextField();
rootNode.add(firstValue, 1, 0);
rootNode.add(new Label("Toatal is:"), 0, 5);
Button aButton = new Button("Calculate");
rootNode.add(aButton, 1, 2);
GridPane.setHalignment(aButton, HPos.LEFT); //set the alignment
TextField result = new TextField(); // label for result
result.setEditable(false);
rootNode.add(result, 1, 5);
TextField tax = new TextField();
rootNode.add(new Label("Tax:"), 0, 3); // label for tax
tax.setEditable(false);
rootNode.add(tax,1,3);
TextField tip = new TextField();
rootNode.add(new Label("Tip:"), 0, 4); //label for tip
tip.setEditable(false);
rootNode.add(tip,1,4);
aButton.setOnAction(e ->{
Float value1 = Float.valueOf(firstValue.getText());
Float value2 =(value1*18)/100; //calculating tip
Float value3 = (value1*7)/100; //calculating tax
Float r = value1+value2+value3 ; // total of all three amounts
tax.setText(value3.toString());
tip.setText(value2.toString());
result.setText(r.toString());
}
}
primaryStage.setScene(myScene); // add scene to stage
primaryStage.show(); // show window
public static void main(String[] args)
{
// launch the application
launch(args);
}
}

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

- Hi guys, I need help correcting my code. It's supposed to create a slideshow however doesn't seem to be working. Any advice or tweaks? Would be appreciated. import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.EventQueue; import java.awt.FlowLayout; import java.awt.HeadlessException; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.Color; public class SlideShow extends JFrame { //Declare Variables private JPanel slidePane; private JPanel textPane; private JPanel buttonPane; private CardLayout card; private CardLayout cardText; private JButton btnPrev; private JButton btnNext; private JLabel lblSlide; private JLabel lblTextArea; /** * Create the application. */ public SlideShow() throws HeadlessException { initComponent(); } /** * Initialize the contents of the frame. */ private void initComponent() {…arrow_forwardDraw black vertical lines with the first line at the very right of the canvas. Thesubsequent lines are drawn from right to left on the canvas to the mouseposition. All lines should be 5 pixels apart. using openprocessing and p5 javascript languagearrow_forwardWhat is interesting and difficult about GUI concepts in Java? For instance event handlers, layout managers, frames, panels. polymorphism, JavaFX.arrow_forward
- Create a class RectangleExample in eclipse. Copy the following code into the class. RectangleExample.java package mypackage; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.shape.Rectangle; public class RectangleExample extends Application { Rectangle rect1, rect2; @Override public void start(Stage stage) { Group root = new Group(); //Drawing a Rectangle rect1 = new Rectangle(); //Setting the properties of the rectangle rect1.setX(20.0f); rect1.setY(20.0f); rect1.setWidth(300.0f); rect1.setHeight(10.0f); rect1.setFill(javafx.scene.paint.Color.RED); //Add to a Group object root.getChildren().add(rect1); //Drawing a Rectangle rect2 = new Rectangle(); //Setting the properties of the rectangle rect2.setX(20.0f); rect2.setY(40.0f); rect2.setWidth(200.0f); rect2.setHeight(10.0f); rect2.setFill(javafx.scene.paint.Color.GREEN); //Add to a Group object root.getChildren().add(rect2); //Creating a scene…arrow_forwardWhat is Object Snap? What is Object Snap? Object Snap is used to specify a precise location on the objects. Object Snap is a rectangular pattern of lines over the drawing area. Object Snap restricts the movement of the crosshairs cursor to an interval that you define. Object Snap restricts cursor movement to specified angles.arrow_forwardCan you show me where and how to add an image folder (Create a pane to hold the images views) with gif images on this code, to hold image views. code is below import javafx.application.Application;import javafx.scene.Scene;import javafx.scene.image.Image;import javafx.scene.image.ImageView;import javafx.scene.layout.GridPane;import javafx.stage.Stage; public class ex1401 extends Application {@Override public void start(Stage primaryStage) { /** pane to hold four images */GridPane p= new GridPane();p.add(new ImageView(new Image("image/uk.gif")), 0, 0);p.add(new ImageView(new Image("image/ca.gif")), 1, 0);p.add(new ImageView(new Image("image/china.gif")), 0, 1);p.add(new ImageView(new Image("image/us.gif")), 1, 1); Scene s= new Scene(p);primaryStage.setTitle("Exercise_14_01");primaryStage.setScene(s);primaryStage.show(); } }arrow_forward
- Your animation must make use of DrawingPanel.java. Draw an animation that should have at 4 - 6 different "effects" or "movements. PLEASE HELP!!! I cannot submit the old code as I got help from one of you guys before since this is the old one.arrow_forwardWhen using solid modeling, the designer has the option of molding and sculpting the item rather than building it out of a collection of lines. Explain?arrow_forwardYour animation must make use of DrawingPanel.java (from Chapter 3G). Draw an animation that should have at 4 - 6 different "effects" or "movements. PLEASE HELP!!!arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





