The assignment number, your name, StudentID, Lecture day/time, and a class description need to be included at the top of each file/class.
A description of each method is also needed. Some additional comments inside of methods (especially for a main method) to explain code that are hard to follow should be written.
New Skills to be Applied
In addition to what has been covered in previous assignments, the use of the following items, discussed
in class, will probably be needed:
JavaFX, ArrayList
Classes may be needed:
Button, TextField, TextArea, Label, CheckButton, and ActionHandler. You may use other classes.
Program Description
Class Diagram:
Write a Java program that generates GUI (Graphical User Interface). Your program should provide labels
and textfields to a user to enter information regarding clubs.
The GUI program should contain two tabs. The first tab is labeled Club creation and the second tab is labeled Club Selection.
(The size of the applet here is approximately 900 X 400).
The section under the first tab should be divided into two parts:
The left part contains labels, textfields, and a button for a user to enter a club information. The right part shows No Club at the beginning (it is done using TextArea).
A user can enter the information of a club, and push Create a Club button.
Then the club information should appear on the right hand side panel (note that the format of the club information can use toString() method of the Club class). A message Club added should also appear with red color at the top of the panel.
Error handling:
- If a user forgets to enter information into text field and pushes Create a Club button, show a message Please fill all fields with red color, and nothing should be added to the right hand side panel.
- If a user enters non integer in the field for the number of member, and pushes Create a club button, show a message Please enter an integer for a number of members. with red color and nothing should be added to the right hand side panel.
After entering multiple clubs, the GUI will have the following appearance.
Under the Club Selection tab, a user can select from those created clubs. The list of created clubs should be made using a pane containing multiple check boxes. Above the pane containing check boxes, there should be a label to display Select some clubs. Below the pane with check boxes, there should be a label to display The total number of members for the selected club(s): 0. However this label should change to show a different number of members every time a check box is checked or unchecked.
The list of clubs under the Club Selection tab should be exactly same as the list under Club Creation tab.
A user can check some check boxes. Every time one of the check boxes in the pane is checked or unchecked, then your program should compute the total number of members of the selected (checked) clubs and it needs to be updated in the label being displayed below.
A user should be able to go back and forth between Club Creation tab and Club Selection tab, and these two panels need to have the same list of clubs.
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<ActionEvent> interface. Thus you need to define its handle method that is supposed to check which check boxes are checked, and compute and update the total number of members of selected clubs whenever one check box is checked or unchecked.
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<ActionEvent> interface. Thus the ButtonHandler needs to have a definition for handle method that adds some information of a club to the list and does error handling. See the UML class diagram for the parameter and return type of this method. In the handle method, you need to extract the information from the textfields. Then you can instantiate an object of the Club class and set its variable values using these values from the textfields. You can use the toString( ) method of the Club object to display the information on the textarea on the right hand side and also add the Club object to the clubList.
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:
Attributename | 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. |
Reviews
There are no reviews yet.