Question: when i run my code, i can't get anything. what is problem? import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.layout.*; import javafx.scene.control.*; import javafx.stage.Stage; import
when i run my code, i can't get anything.
what is problem?
import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.layout.*; import javafx.scene.control.*; import javafx.stage.Stage; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javax.swing.*; public class RetailPriceCalculator extends Application implements EventHandler{ TextField textWholesale; TextField textMarkup; Button btn; @Override public void start(Stage primaryStage) throws Exception { HBox root = new HBox(); root.setSpacing(10); root.setPadding(new Insets(15,20,10,10)); Label lbl1 = new Label("Enter the wholesale cost"); root.getChildren().add(lbl1); textWholesale = new TextField(""); textWholesale.setPrefWidth(110); root.getChildren().add(textWholesale); Label lbl2 = new Label("Enter the markup cost"); root.getChildren().add(lbl2); textMarkup = new TextField(""); textMarkup.setPrefWidth(110); root.getChildren().add(textMarkup); btn = new Button("calculate retail Price"); root.getChildren().add(btn); Scene scene = new Scene(root,550,250); primaryStage.setTitle("Retail Price calculator"); primaryStage.setScene(scene); primaryStage.show(); } public void handle(ActionEvent event) { double wholesalecost, markupPct, retail; wholesalecost = Double.parseDouble(textWholesale.getText()); markupPct = Double.parseDouble(textMarkup.getText()); retail = wholesalecost + (wholesalecost * markupPct / 100); Alert alert = new Alert(Alert.AlertType.INFORMATION); if(event.getSource() == btn) { alert.setTitle("Message Box"); alert.setHeaderText(""); alert.setContentText(String.format("The Retail Price is %$",+retail)); alert.showAndWait(); } } public static void main(String[] args) { launch(args); } }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
