Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

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 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 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:

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:
  1. 2 points: Appropriate components such as textfields, labels, etc. are shown under the "Club Creation" and "Club Select" tabs.
  2. 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.
  3. 1 point: Error handing in case some field is not filled.
  4. 1 point: Error handing in case non integer is entered for the number of members (under Club Creation).
  5. 1 point: Whenever a new club is added in the club creation panel, its corresponding CheckBox is added in the club selection pane.
  6. 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.wimage text in transcribed

You need to add more codes to complete Assignment6, CreatePane, SelectPane.

// Assignment6:

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

{

ArrayList clubList;

//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 ArrayList clubList;

//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

// Club:

public class Club

{

private String clubName;

private int numberOfMembers;

private String university;

//Constructor to initialize all member variables

public Club()

{

clubName = "?";

university = "?";

numberOfMembers = 0;

}

//Accessor methods

public String getClubName()

{

return clubName;

}

public String getUniversity()

{

return university;

}

public int getNumberOfMembers()

{

return numberOfMembers;

}

//Mutator methods

public void setClubName(String someClubName)

{

clubName = someClubName;

}

public void setUniversity(String someUniversity)

{

university = someUniversity;

}

public void setNumberOfMembers(int someNumber)

{

numberOfMembers = someNumber;

}

//toString() method returns a string containg its name, number of members, and

university

public String toString()

{

String result = " Club Name:\t\t" + clubName

+ " Number Of Members:\t" + numberOfMembers

+ " University:\t\t" + university

+ " ";

return result;

}

}

HIIUlld Slale UMVEI SILY, CSL203 Spring 2020. Assignment Application defined in javafx.application Club CreatePane -clubList:ArrayList -selectPane. SelectPane Assignment +CreatePane(ArrayList SelectPane) -tabPane:TabPane -createPane:CreatePane -selectPane:SelectPane -clubList.ArrayList Select Pane -clubList:ArrayList +start(Stage) void +SelectPane(ArrayList) +updateClubList(Club) SelectionHandler ButtonHandler +handle(ActionEvent) void +handle(ActionEvent) void HIIUlld Slale UMVEI SILY, CSL203 Spring 2020. Assignment Application defined in javafx.application Club CreatePane -clubList:ArrayList -selectPane. SelectPane Assignment +CreatePane(ArrayList SelectPane) -tabPane:TabPane -createPane:CreatePane -selectPane:SelectPane -clubList.ArrayList Select Pane -clubList:ArrayList +start(Stage) void +SelectPane(ArrayList) +updateClubList(Club) SelectionHandler ButtonHandler +handle(ActionEvent) void +handle(ActionEvent) void

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is the NPV for where the #### are in the bottom left corner.

Answered: 1 week ago

Question

How flying airoplane?

Answered: 1 week ago