You may adjust the code as you want. Thank you! CODING HERE: import javafx.appli
ID: 3742268 • Letter: Y
Question
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 = new Label("Cost:");
private Label amountOwedLabel = new Label("Amount Owed:");
// add four textfields for labels
private TextField itemName = new TextField();
private TextField number = new TextField();
private TextField cost = new TextField();
private TextField amountOwed = new TextField();
// add buttons
private Button btnCalc = new Button("Calculate"); //To calculate the result
private Button btnSave = new Button("Save"); //To save the result
private Button btnClear = new Button("Clear"); //To clear the result
private Button btnExit = new Button("Exit"); //To exit the program
private Button btnLoad = new Button("Load"); //To load the data
private Button btnPrev = new Button("<Prev"); //To previous the data
private Button btnNext = new Button(">Next"); //To next the data
private Button btnCalcSave = new Button("Calculate & Save"); //To calculate then save
// Main of this GUI class
public static void main(String [] args)
{
launch(args);
} // end of main
public void start(Stage _stage) throws Exception
{
stage = _stage; // save stage as an attribute
stage.setTitle("Quoc Huynh Item Orders Calculator"); // set the text in the title bar
layout = new BorderPane();
FlowPane loTop = new FlowPane(10, 10);
loTop.setAlignment(Pos.CENTER);
loTop.getChildren().add(itemLabel);
loTop.getChildren().add(itemName);
loTop.getChildren().add(numberLabel);
loTop.getChildren().add(number);
loTop.getChildren().add(costLabel);
loTop.getChildren().add(cost);
loTop.getChildren().add(amountOwedLabel);
loTop.getChildren().add(amountOwed);
layout.setTop(loTop);
scene = new Scene(layout, 300, 200);
stage.setScene(scene);
stage.show();
}
public void handle(ActionEvent ae)
{
Button btn = (Button)ae.getSource();
}
}
Explanation / Answer
Hi. please find the answer above.. In case of any doubts, please ask in comments. If the answer helps you, please upvote. Thanks!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.