Minimal Submitted Files: You are required, but not limited, to turn in the follo
ID: 3795993 • Letter: M
Question
Minimal Submitted Files:
You are required, but not limited, to turn in the following source files:
Assignment6.java (The Assignment6 class extends JApplet)
Flight.java
Schedule.java
CreatePanel.java - to be completed (it extends JPanel and contains ButtonListener nested class)
SelectPanel.java - to be completed (it extends JPanel and contains ButtonListener nested class)
You can download the above files and use them to complete this assignment. You might need to add more methods than the specified ones.
Program Description
Suggested Class Diagram:
Write a Java program that constructs an Applet. Your program should provide labels and textfields to a user to enter information regarding flights.
The Applet (JApplet) of your program should contain two tabs. The first tab is labeled "Flight Creation" and the second tab is labeled "Flight Selection".
(The size of the applet here is approximately 800 X 200).
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 some flight information. The right part shows "No flight" at the beginning (it is done using JTextArea).
Class description:
SelectPanel
SelectPanel class extends JPanel defined in javax.swing package. It should contain at least the following instance variable:
Attribute name
Attribute type
Description
flightList
ArrayList
a list of Flight objects.
This class should have a constructor:
public SelectPanel(ArrayList flightList)
where the parameter "flightList" is passed from the Assignment6 class. The constructor layouts and organizes components in this panel. You will be adding more variables (components) than what is listed here, including a JLabel, a JTextField,and JCheckBoxs.
public void addCheckBox(Flight flight1)
This method create an object of JCheckBox using the toString of the Flight object parameter. This JCheckBox object needs to be added to the panel to be displayed. An object of CheckBoxListener class needs to be added to this JCheckBox so that it listens when a user checks or un-checks. This method needs to be called from the actionPerformed of ButtonListener of the CreatePanel class when a new Flight object is added.
This class contains a nested class called CheckBoxListener class that implements ItemListener interface. Thus you need to define its itemStateChanged method that is supposed to verify which check boxes are checked and add the airfare of the corresponding flights and display the total purchase amount to the JLabel using the dollar format (Please use NumberFormat class).
CreatePanel:
CreatePanel extends JPanel defined in the javax.swing package. It should contain at least the following instance variable:
Attribute name
Attribute type
Description
flightList
ArrayList
a list of Flight objects.
selectPanel
SelectPanel
an object of SelectPanel.
This class should have a constructor:
public CreatePanel(ArrayList flightList, SelectPanel selectPanel)
where the parameter "flightList" is passed from the Assignment6 class and the second parameter is an object of SelectPanel. The constructor layouts and organizes components in this panel. You will be adding more variables (components) than what is listed here, including labels, textfields, a button, and a text area.
This class contains a nested class called ButtonListener class that implements ActionListener interface. Thus the ButtonListener needs to have a definition for actionPerformed method that adds some flight information to the list and does error handling. See the UML class diagram for the parameter and return type of this method. In the actionPerformed, you need to extract the information from the textfields for flight information. Then you can instantiate an object of the Flight class using the information. You can use the toString( ) method of the Flight object to display the information on the textarea on the right hand side and also add the Flight object to the "flightList". This is also where addCheckBox( ) method of the SelectPanel class needs to be called with its object "selectPanel". so that a new flight is added to the CreatePanel, the same one is added to the SelectPanel.
FILES:
1) Assignment 6:
2) Flight (no changes required):
3) Schedule (no changes required):
4) CreatePanel - to be completed (it extends JPanel and contains ButtonListener nested class) :
5) SelectPanel - to be completed (it extends JPanel and contains ButtonListener nested class):
Attribute name
Attribute type
Description
flightList
ArrayList
a list of Flight objects.
Schedule Flight E Assignment6 -tPane:JTabbedPane -createPanel CreatePanel -selectPanel SelectPanel -flightList ArrayList nit void Check Box Listener titemStateChanged(ItemEvent):void JApplet defined in javax.swing JPanel defined in javax.swing Create Panell Select Panel -flight List:ArrayList -flightList: AmayList -selectPanel Select Panel +Select Panel (ArrayList) +addCheck Box(Flight):void +CreatePanel ArrayList,SelectPanel) Button Listener Arizona State University CSE205, Spring 2017 Assignment tactionPerformed(ActionEvent):void