Question
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; import java.util.ArrayList; public class Assignment6 extends Application { private TabPane tabPane; private CreatePane
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; import java.util.ArrayList; public class Assignment6 extends Application { private TabPane tabPane; private CreatePane createPane; private SelectPane selectPane; private ArrayList clubList; public void start(Stage stage) { StackPane root = new StackPane(); //clubList to be used in both createPane & selectPane clubList = new ArrayList(); selectPane = new SelectPane(clubList); createPane = new CreatePane(clubList, selectPane); tabPane = new TabPane(); Tab tab1 = new Tab(); tab1.setText("Club Creation"); tab1.setContent(createPane); Tab tab2 = new Tab(); tab2.setText("Club Selection"); tab2.setContent(selectPane); tabPane.getSelectionModel().select(0); tabPane.getTabs().addAll(tab1, tab2); root.getChildren().add(tabPane); Scene scene = new Scene(root, 900, 400); stage.setTitle("Club Selection Apps"); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } }
//createPane:
import java.util.ArrayList; import javafx.scene.layout.HBox; import javafx.event.ActionEvent; //**Need to import import javafx.event.EventHandler; //**Need to import //import all other necessary javafx classes here //---- public class CreatePane extends HBox { ArrayListclubList; //The relationship between CreatePane and SelectPane is Aggregation private SelectPane selectPane; //constructor public CreatePane(ArrayList list, SelectPane sePane) { this.clubList = list; this.selectPane = sePane; //initialize each instance variable (textfields, labels, textarea, button, etc.) //and set up the layout //---- //create a GridPane hold those 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 CreatePane. //---- //the right half of the CreatePane is simply a TextArea object //Note: a ScrollPane will be added to it automatically when there are no //enough space //Add the left half and right half to the CreatePane //Note: CreatePane extends from HBox //---- //register/link source object with event handler //---- } //end of constructor //Create a ButtonHandler class //ButtonHandler listens to see if the button "Create" is pushed or not, //When the event occurs, it get a club's Title, its number of members, and its university //information from the relevant text fields, then create a new club and add it inside //the clubList. Meanwhile it will display the club's information inside the text area. //using the toString method of the Club class. //It also does error checking in case any of the textfields are empty, //or a non-numeric value was entered for its number of members private class ButtonHandler implements EventHandler { //Override the abstact method handle() public void handle(ActionEvent event) { //declare any necessary local variables here //--- //when a text field is empty and the button is pushed //if ( //---- ) //{ //handle the case here //} //else //for all other cases //{ //when a non-numeric value was entered for its number of members //and the button is pushed //you will need to use try & catch block to catch //the NumberFormatException //---- //When a club of an existing club name in the list //was attempted to be added, do not add it to the list //and display a message "Club not added - duplicate" //at the end, don't forget to update the new arrayList //information on the SelectPanel //---- //} } //end of handle() method } //end of ButtonHandler class }
//SelectPane:
import javafx.scene.control.Label; import javafx.scene.control.CheckBox; import javafx.scene.layout.*; import javafx.event.ActionEvent; //**Need to import import javafx.event.EventHandler; //**Need to import import java.util.ArrayList; import javafx.collections.ObservableList; import javafx.scene.Node; //import all other necessary javafx classes here //---- public class SelectPane extends BorderPane { private ArrayListclubList; //constructor public SelectPane(ArrayList list) { //initialize instance variables this.clubList = list; //set up the layout //---- //create an empty pane where you can add check boxes later //---- //SelectPane is a BorderPane - add the components here //---- } //end of constructor //This method uses the newly added parameter Club object //to create a CheckBox and add it to a pane created in the constructor //Such check box needs to be linked to its handler class public void updateClubList(Club newClub) { //------- } //create a SelectionHandler class private class SelectionHandler implements EventHandler { //Override the abstact method handle() public void handle(ActionEvent event) { //When any radio button is selected or unselected //the total number of members of selected clubs should be updated //and displayed using a label. } } //end of SelectHandler class } //end of SelectPane class
Class description
SelectPane
SelectPane class should contain at least the following instance variable:
Attribute name | Attribute type | Description |
clubList | ArrayList | a list of club objects. |
This class should have a constructor:
public SelectPane(ArrayList clubList)
where the parameter "clubList" is passed from the Assignment6 class. The constructor layouts and organizes nodes/components in this panel. You will be adding more variables (nodes/components) than what is listed here, including check boxes, and labels. An object of some pane (maybe VBox) needs to be created, where check boxes will be added later on, and it needs to be added to this SelectPane.
public void updateClubList(Club newClub)
This method creates an object of CheckBox using the toString method of the parameter object newClub. Then the check box should be added to the pane that was initially added to the SelectPane in the constructor.
This class contains a nested class called SelectionHandler class that implements EventHandler
CreatePane
CreatePane should contain at least the following instance variable:
Attribute name | Attribute type | Description |
clubList | ArrayList | a list of Club objects. |
selectPane | SelectPane | an object of SelectPane. |
This class should have a constructor:
public CreatePane(ArrayList clubList, SelectPane selectPane)
where the parameter "clubList" is passed from the Assignment6 class and the second parameter is an object of SelectPane. The constructor layouts and organizes components in this panel. You will be adding more variables (nodes/components) than what is listed here, including labels, textfields, a button, and a text area.
This class contains a nested class called ButtonHandler class that implements EventHandler
Assignment6 class
Assignment6 extends Application defined in javafx.application package and should initialize itself by setting its size. It contains at least following instance variables:
Attribute name | Attribute type | Description |
clubList | ArrayList | a list of club objects. It will be used in both CreatePane and SelectPane. |
selectPane | SelectPane | an object of SelectPane. |
createPane | CreatePane | an object of CreatePane. |
tabPane | TabPane | an object of TabPane. It will contain createPane and selectPane under each tab. |
Grading Policy:
- submit assignment on time
- indicate assignment number, name, lecture time, and description of each class clearly in each submitted java file
- 5 pts - Documentation (header with your name, your information, and program description for every class/file and comment/description within your code for every method) 1 pt - Indentation and spacing (easy to read) 6 pts - Required classes/methods and functionalities implemented 8 pts - Your program minimally need to have the following functionalities:
- 2 points: Appropriate components such as textfields, labels, etc. are shown under the "Club Creation" and "Club Select" tabs.
- 1 point: When the "Create a Club" button is pushed, the club information is added on the right panel in the correct order and the message of "club added" shows up.
- 1 point: Error handing in case some field is not filled.
- 1 point: Error handing in case non integer is entered for the number of members (under Club Creation).
- 1 point: Whenever a new club is added in the club creation panel, its corresponding CheckBox is added in the club selection pane.
- 2 points: When a check box in the club selection pane is checked or unchecked, the total number of members for selected clubs needs to be computed and updated in the label to display it.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started