CSE javafx

juju030
InputPane.java

package application; import java.util.ArrayList; import javafx.scene.layout.HBox; import javafx.event.ActionEvent; import javafx.event.EventHandler; //import all other necessary javafx classes here //---- import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import javafx.scene.layout.StackPane; public class InputPane extends HBox { //components ArrayList < Order > orderList; //The relationship between InputPane and HandlePane is Aggregation private HandlePane handlePane; //declare other necessary GUI components and variables here //---- //constructor public InputPane(ArrayList < Order > list, HandlePane pane) { this.orderList = list; this.handlePane = pane; //initialize each instance variable (textfields, labels, textarea, button, etc.) //and set up the layout //---- //create a GridPane hold the labels & text fields. //you can choose to use setPadding() or setHgap(), setVgap() //to control the spacing and gap, etc. //---- //You might need to create a sub pane to hold the button //---- //Set up the layout for the left half of the InputPane //---- //the right half of the InputPane is simply a TextArea object //Note: a ScrollPane will be added automatically when there are no //enough space //---- //Add the left half and right half to the InputPane //Note: InputPane extends from HBox //---- //register source object with event handler //---- } //end of constructor //Step 2: Create a ButtonHandler class //ButtonHandler listen to see if the button "Place an order" is pushed or not, //When the event occurs, it get an order's product name, quantiy, unit price //from the relevant text fields, then create a new Order object and add it inside //the orderList. Meanwhile it will display the order's total cost and other info. inside the text area. //It also does error checking in case any of the textfields are empty private class ButtonHandler implements EventHandler < ActionEvent > { //Override the abstact method handle() public void handle(ActionEvent e) { //declare any necessary local variables here //--- //when one text field is empty and the button is pushed //display msg "Please fill all fields" if ( //---- ) { //handle the case here } else { //when a non-numeric value was entered for quantity or price //and the button is pushed //you will need to use try & catch block to catch //the NumberFormatException //---- //When a duplicated order was attempted to be added, do not //add it to the list. Instead displaying msg "Order not added - duplicate" //---- //When everything is correct, create a new Order object and //add it inside orderList //---- //Next, don't forget to update the new arrayList information //on the ListView of the handlePane //---- } } //end of handle() method } //end of ButtonHandler class }