SlideShare a Scribd company logo
1 of 6
Download to read offline
The first part of the assignment involves creating very basic GUI controls: a frame, panel, and
slider.
Create a JFrame. Add a title to the frame called Flight Reservation. Set the frame size to 475 by
500 pixels. Create a JPanel inside of the frame. You will be adding all of your UI components to
this JPanel. [6 pts]
Inside of the panel, create a label that says "Choose Color." Right below it, make a slider that
changes the background color of the panel when the slider is moved to a particular color. The
slider values should be RGB color values from 0 to 255 (or black to white). Assume that the
RGB values for red, green, and blue are the same value - for instance: (240, 240, 240). The slider
label's text should be replaced with the RGB value that the slider is currently on. [8 pts]
Q2: Add functionality to search for an Itinerary.
Create labels and text fields that allow the user to enter an airline, a source airport, and a
destination airport, as well as the departure time and the arrival time to search for one or more
available flights in an Itinerary. Also, create a ComboBox that will allow the user to select from
a list of flight Itineraries. Each item in the ComboBox represents an Itinerary element, e.g. the
first comboBoxelement is the first Itinerary in the array. [15 pts]
Make sure all text fields have error checking and exception handling for invalid input. For
example, if the user enters an integer as a departure time instead of a String (ie 1200 instead of
12:00 PM), a JOptionPane error message should appear stating, "Incorrect format for departure
time." If the airline they entered is not in the Airline enum, then the option pane should say,
"Airline unavailable. Please choose a different airline." If the airport they entered is not in the
Airport enum, then the option pane should say, "Unknown city." Make sure the times are in
hh:mm format. [8 pts]
Q3: Create a button that says Search and a button that says View. When the user clicks Search,
the combobox will get populated. When the user clicks View, if all the fields are filled out and
have valid input, a JOptionPane with a message dialog should appear stating, "Flight search
successful!" The frame should open a new JFrame with the title, "Flight Information," and a
size of 475 by 500 pixels. This frame has the flight information displayed in a JTextArea. [6 pts]
Q4: On the Flight Information frame, you will need to display information for each Flight in the
Itinerary [7 points]:
Airline: Display the airline
Model: The model of the airplane should be generated from the Plane object inside of the Flight
class.
Departure Airport: Display the source airport
Departure City: Display the departure city based on the departure airport (use the
getAirportCity() method you implemented in the Unit 3 assignment to get the airport city)
Destination Airport: Display the destination airport
Destination City: Display the destination city based on the destination airport (use the
getAirportCity() method again)
Departure Time: Display the departure time
Arrival Time: Display the arrival time
Flight Number: A flight number should be selected based on the airline, followed by the Flight's
number.
Cost: Display the total cost, which should be computed by the Itinerary object.
Solution
I have given you the sample codes with inline commands.
The code shown below is for the question number 1 and the remaining answers you can do in
similar manner.
create panel for each module and add every module into the frame.
Pannel layout can be decided by setting the layout property
eg: " panel.setLayout(new GridLayout(6, 2, 15, 0));"
For better understanding please split all the classes into separate files.
void java.awt.Window.pack() method packs the panel properly into the frame eg:frame.pack(“)
it avoids missing the panel elements from the frame
ChangeListner extends event Listener so that it capture the changes in the slider and immediate
effect can be seen in the panel
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class test extends JFrame {
public test() {
JFrame frame = new JFrame("JFrame");
frame.setTitle("Flight Reservation");
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
panel.add(new ColourPick());
frame.add(panel);
frame.setSize(475, 500);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
// add this code for packing the panel inside frame
frame.pack();
}
public static void main(String arg[]) {
new test();
}
}
class ColourPick extends JPanel {
DrawingCanvas canvas = new DrawingCanvas();
JLabel rgbValue = new JLabel("");
JSlider sliderR, sliderG, sliderB, sliderH, sliderS, sliderBr,
sliderAlpha;
public ColourPick() {
sliderR = getSlider(0, 255, 0, 50, 5);
sliderG = getSlider(0, 255, 0, 50, 5);
sliderB = getSlider(0, 255, 0, 50, 5);
sliderH = getSlider(0, 10, 0, 5, 1);
sliderS = getSlider(0, 10, 0, 5, 1);
sliderBr = getSlider(0, 10, 0, 5, 1);
sliderAlpha = getSlider(0, 255, 255, 50, 5);
JPanel panel = new JPanel();
JLabel label = new JLabel("Choose Color");
// add the panel size here according to your needs
panel.setLayout(new GridLayout(6, 2, 15, 0));
panel.add(label);
panel.add(new JLabel("R-G-B Sliders (0 - 255)"));
panel.add(new JLabel("H-S-B Sliders (ex-1)"));
panel.add(sliderR);
panel.add(sliderH);
panel.add(sliderG);
panel.add(sliderS);
panel.add(sliderB);
panel.add(sliderBr);
panel.add(new JLabel("Alpha Adjustment (0 - 255): ", JLabel.RIGHT));
panel.add(sliderAlpha);
panel.add(new JLabel("RGB Value: ", JLabel.RIGHT));
rgbValue.setBackground(Color.white);
rgbValue.setForeground(Color.black);
rgbValue.setOpaque(true);
panel.add(rgbValue);
add(panel, BorderLayout.SOUTH);
add(canvas);
}
public JSlider getSlider(int min, int max, int init, int mjrTkSp, int mnrTkSp) {
JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, init);
slider.setPaintTicks(true);
slider.setMajorTickSpacing(mjrTkSp);
slider.setMinorTickSpacing(mnrTkSp);
slider.setPaintLabels(true);
slider.addChangeListener(new SliderListener());
return slider;
}
class DrawingCanvas extends Canvas {
Color color;
int redValue, greenValue, blueValue;
int alphaValue = 255;
float[] hsbValues = new float[3];
public DrawingCanvas() {
setSize(350, 350);
color = new Color(0, 0, 0);
setBackgroundColor();
}
public void setBackgroundColor() {
color = new Color(redValue, greenValue, blueValue, alphaValue);
setBackground(color);
}
}
class SliderListener implements ChangeListener {
public void stateChanged(ChangeEvent e) {
JSlider slider = (JSlider) e.getSource();
if (slider == sliderAlpha) {
canvas.alphaValue = slider.getValue();
canvas.setBackgroundColor();
} else if (slider == sliderR) {
canvas.redValue = slider.getValue();
displayRGBColor();
} else if (slider == sliderG) {
canvas.greenValue = slider.getValue();
displayRGBColor();
} else if (slider == sliderB) {
canvas.blueValue = slider.getValue();
displayRGBColor();
} else if (slider == sliderH) {
canvas.hsbValues[0] = (float) (slider.getValue() * 0.1);
displayHSBColor();
} else if (slider == sliderS) {
canvas.hsbValues[1] = (float) (slider.getValue() * 0.1);
displayHSBColor();
} else if (slider == sliderBr) {
canvas.hsbValues[2] = (float) (slider.getValue() * 0.1);
displayHSBColor();
}
canvas.repaint();
}
public void displayHSBColor() {
canvas.color = Color.getHSBColor(canvas.hsbValues[0],
canvas.hsbValues[1], canvas.hsbValues[2]);
canvas.redValue = canvas.color.getRed();
canvas.greenValue = canvas.color.getGreen();
canvas.blueValue = canvas.color.getBlue();
sliderR.setValue(canvas.redValue);
sliderG.setValue(canvas.greenValue);
sliderB.setValue(canvas.blueValue);
canvas.color = new Color(canvas.redValue, canvas.greenValue,
canvas.blueValue, canvas.alphaValue);
canvas.setBackground(canvas.color);
}
public void displayRGBColor() {
canvas.setBackgroundColor();
Color.RGBtoHSB(canvas.redValue, canvas.greenValue, canvas.blueValue,canvas.hsbValues);
sliderH.setValue((int) (canvas.hsbValues[0] * 10));
sliderS.setValue((int) (canvas.hsbValues[1] * 10));
sliderBr.setValue((int) (canvas.hsbValues[2] * 10));
rgbValue.setText(Integer.toString(canvas.color.getRGB() & 0xffffff, 16));
}
}
}

More Related Content

Similar to The first part of the assignment involves creating very basic GUI co.pdf

Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfatulkapoor33
 
Please help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdfPlease help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdfinfo750646
 
Please help with creating a javascript file to produce the outcome bel (1).pdf
Please help with creating a javascript file to produce the outcome bel (1).pdfPlease help with creating a javascript file to produce the outcome bel (1).pdf
Please help with creating a javascript file to produce the outcome bel (1).pdfpankajsingh316693
 
Java Airline Reservation System – Travel Smarter, Not Harder.pdf
Java Airline Reservation System – Travel Smarter, Not Harder.pdfJava Airline Reservation System – Travel Smarter, Not Harder.pdf
Java Airline Reservation System – Travel Smarter, Not Harder.pdfSudhanshiBakre1
 
Change transport system in SAP
Change transport system in SAP Change transport system in SAP
Change transport system in SAP chinu141
 
I really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfI really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfpasqualealvarez467
 
Training Storyboard
Training StoryboardTraining Storyboard
Training Storyboardhaven832
 
XIX PUG-PE - Pygame game development
XIX PUG-PE - Pygame game developmentXIX PUG-PE - Pygame game development
XIX PUG-PE - Pygame game developmentmatheuscmpm
 
Creating an Uber Clone - Part III - Transcript.pdf
Creating an Uber Clone - Part III - Transcript.pdfCreating an Uber Clone - Part III - Transcript.pdf
Creating an Uber Clone - Part III - Transcript.pdfShaiAlmog1
 
Csphtp1 07
Csphtp1 07Csphtp1 07
Csphtp1 07HUST
 
Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Muhammad Shebl Farag
 
Java Graphics
Java GraphicsJava Graphics
Java GraphicsShraddha
 
Jetpack Compose - A Lightning Tour
Jetpack Compose - A Lightning TourJetpack Compose - A Lightning Tour
Jetpack Compose - A Lightning TourMatthew Clarke
 
Scala+swing
Scala+swingScala+swing
Scala+swingperneto
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Appletbackdoor
 
Csphtp1 16
Csphtp1 16Csphtp1 16
Csphtp1 16HUST
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specificationsrajkumari873
 

Similar to The first part of the assignment involves creating very basic GUI co.pdf (20)

Cs practical file
Cs practical fileCs practical file
Cs practical file
 
Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdf
 
Please help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdfPlease help with creating a javascript file to produce the outcome bel.pdf
Please help with creating a javascript file to produce the outcome bel.pdf
 
Please help with creating a javascript file to produce the outcome bel (1).pdf
Please help with creating a javascript file to produce the outcome bel (1).pdfPlease help with creating a javascript file to produce the outcome bel (1).pdf
Please help with creating a javascript file to produce the outcome bel (1).pdf
 
Java Airline Reservation System – Travel Smarter, Not Harder.pdf
Java Airline Reservation System – Travel Smarter, Not Harder.pdfJava Airline Reservation System – Travel Smarter, Not Harder.pdf
Java Airline Reservation System – Travel Smarter, Not Harder.pdf
 
Ex32018.pdf
Ex32018.pdfEx32018.pdf
Ex32018.pdf
 
Change transport system in SAP
Change transport system in SAP Change transport system in SAP
Change transport system in SAP
 
I really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfI really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdf
 
Training Storyboard
Training StoryboardTraining Storyboard
Training Storyboard
 
XIX PUG-PE - Pygame game development
XIX PUG-PE - Pygame game developmentXIX PUG-PE - Pygame game development
XIX PUG-PE - Pygame game development
 
Creating an Uber Clone - Part III - Transcript.pdf
Creating an Uber Clone - Part III - Transcript.pdfCreating an Uber Clone - Part III - Transcript.pdf
Creating an Uber Clone - Part III - Transcript.pdf
 
Csphtp1 07
Csphtp1 07Csphtp1 07
Csphtp1 07
 
Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1
 
Java Graphics
Java GraphicsJava Graphics
Java Graphics
 
Jetpack Compose - A Lightning Tour
Jetpack Compose - A Lightning TourJetpack Compose - A Lightning Tour
Jetpack Compose - A Lightning Tour
 
Scala+swing
Scala+swingScala+swing
Scala+swing
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
 
Csphtp1 16
Csphtp1 16Csphtp1 16
Csphtp1 16
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specifications
 
Visualbasic tutorial
Visualbasic tutorialVisualbasic tutorial
Visualbasic tutorial
 

More from neerajsachdeva33

Can you please explain those risk management from Kaiser Permanente.pdf
Can you please explain those risk management from Kaiser Permanente.pdfCan you please explain those risk management from Kaiser Permanente.pdf
Can you please explain those risk management from Kaiser Permanente.pdfneerajsachdeva33
 
A survey of 2630 musicians showed that 372 of them are left-handed. .pdf
A survey of 2630 musicians showed that 372 of them are left-handed. .pdfA survey of 2630 musicians showed that 372 of them are left-handed. .pdf
A survey of 2630 musicians showed that 372 of them are left-handed. .pdfneerajsachdeva33
 
What is other disorder of arteries beside atherosclerosis What.pdf
What is other disorder of arteries beside atherosclerosis What.pdfWhat is other disorder of arteries beside atherosclerosis What.pdf
What is other disorder of arteries beside atherosclerosis What.pdfneerajsachdeva33
 
Why is a egg cell is much larger than a sperm cell Explain in 1-2 p.pdf
Why is a egg cell is much larger than a sperm cell Explain in 1-2 p.pdfWhy is a egg cell is much larger than a sperm cell Explain in 1-2 p.pdf
Why is a egg cell is much larger than a sperm cell Explain in 1-2 p.pdfneerajsachdeva33
 
What type of relationship typically exists between the resident and t.pdf
What type of relationship typically exists between the resident and t.pdfWhat type of relationship typically exists between the resident and t.pdf
What type of relationship typically exists between the resident and t.pdfneerajsachdeva33
 
What is the model for floral induction by day-lengthSolutionB.pdf
What is the model for floral induction by day-lengthSolutionB.pdfWhat is the model for floral induction by day-lengthSolutionB.pdf
What is the model for floral induction by day-lengthSolutionB.pdfneerajsachdeva33
 
What is the difference between a semi-permeable and selectively perm.pdf
What is the difference between a semi-permeable and selectively perm.pdfWhat is the difference between a semi-permeable and selectively perm.pdf
What is the difference between a semi-permeable and selectively perm.pdfneerajsachdeva33
 
what did Linnaeus contribute to taxonomySolutionThe classifica.pdf
what did Linnaeus contribute to taxonomySolutionThe classifica.pdfwhat did Linnaeus contribute to taxonomySolutionThe classifica.pdf
what did Linnaeus contribute to taxonomySolutionThe classifica.pdfneerajsachdeva33
 
We are interested in whether the proportions of female suicide victim.pdf
We are interested in whether the proportions of female suicide victim.pdfWe are interested in whether the proportions of female suicide victim.pdf
We are interested in whether the proportions of female suicide victim.pdfneerajsachdeva33
 
True or false Fruits attract animals that act as pollinators T.pdf
True or false Fruits attract animals that act as pollinators T.pdfTrue or false Fruits attract animals that act as pollinators T.pdf
True or false Fruits attract animals that act as pollinators T.pdfneerajsachdeva33
 
the observed locations of integrated retroviral proviruses within ho.pdf
the observed locations of integrated retroviral proviruses within ho.pdfthe observed locations of integrated retroviral proviruses within ho.pdf
the observed locations of integrated retroviral proviruses within ho.pdfneerajsachdeva33
 
The general name for something that binds to a protein is Select one.pdf
The general name for something that binds to a protein is  Select one.pdfThe general name for something that binds to a protein is  Select one.pdf
The general name for something that binds to a protein is Select one.pdfneerajsachdeva33
 
serial communication, parallel communication, SPI and ADCs. Write .pdf
serial communication, parallel communication, SPI and ADCs. Write .pdfserial communication, parallel communication, SPI and ADCs. Write .pdf
serial communication, parallel communication, SPI and ADCs. Write .pdfneerajsachdeva33
 
Suppose that a heap stores 210 elements. What is its height (show w.pdf
Suppose that a heap stores 210 elements. What is its height (show w.pdfSuppose that a heap stores 210 elements. What is its height (show w.pdf
Suppose that a heap stores 210 elements. What is its height (show w.pdfneerajsachdeva33
 
Oxfam used its existing opt-in e-mail list only for this campaign; i.pdf
Oxfam used its existing opt-in e-mail list only for this campaign; i.pdfOxfam used its existing opt-in e-mail list only for this campaign; i.pdf
Oxfam used its existing opt-in e-mail list only for this campaign; i.pdfneerajsachdeva33
 
Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfneerajsachdeva33
 
JUST DO QUESTION 4 1. When you are preparing a budget where could yo.pdf
JUST DO QUESTION 4 1. When you are preparing a budget where could yo.pdfJUST DO QUESTION 4 1. When you are preparing a budget where could yo.pdf
JUST DO QUESTION 4 1. When you are preparing a budget where could yo.pdfneerajsachdeva33
 
In the paramyxoviruses, cleavage of the F0 protein into two subunits .pdf
In the paramyxoviruses, cleavage of the F0 protein into two subunits .pdfIn the paramyxoviruses, cleavage of the F0 protein into two subunits .pdf
In the paramyxoviruses, cleavage of the F0 protein into two subunits .pdfneerajsachdeva33
 
Information about dengue fever is provided on the following pages. A.pdf
Information about dengue fever is provided on the following pages. A.pdfInformation about dengue fever is provided on the following pages. A.pdf
Information about dengue fever is provided on the following pages. A.pdfneerajsachdeva33
 
A toothcomb, rhinarium or moist nose, and vertical clinging and leapi.pdf
A toothcomb, rhinarium or moist nose, and vertical clinging and leapi.pdfA toothcomb, rhinarium or moist nose, and vertical clinging and leapi.pdf
A toothcomb, rhinarium or moist nose, and vertical clinging and leapi.pdfneerajsachdeva33
 

More from neerajsachdeva33 (20)

Can you please explain those risk management from Kaiser Permanente.pdf
Can you please explain those risk management from Kaiser Permanente.pdfCan you please explain those risk management from Kaiser Permanente.pdf
Can you please explain those risk management from Kaiser Permanente.pdf
 
A survey of 2630 musicians showed that 372 of them are left-handed. .pdf
A survey of 2630 musicians showed that 372 of them are left-handed. .pdfA survey of 2630 musicians showed that 372 of them are left-handed. .pdf
A survey of 2630 musicians showed that 372 of them are left-handed. .pdf
 
What is other disorder of arteries beside atherosclerosis What.pdf
What is other disorder of arteries beside atherosclerosis What.pdfWhat is other disorder of arteries beside atherosclerosis What.pdf
What is other disorder of arteries beside atherosclerosis What.pdf
 
Why is a egg cell is much larger than a sperm cell Explain in 1-2 p.pdf
Why is a egg cell is much larger than a sperm cell Explain in 1-2 p.pdfWhy is a egg cell is much larger than a sperm cell Explain in 1-2 p.pdf
Why is a egg cell is much larger than a sperm cell Explain in 1-2 p.pdf
 
What type of relationship typically exists between the resident and t.pdf
What type of relationship typically exists between the resident and t.pdfWhat type of relationship typically exists between the resident and t.pdf
What type of relationship typically exists between the resident and t.pdf
 
What is the model for floral induction by day-lengthSolutionB.pdf
What is the model for floral induction by day-lengthSolutionB.pdfWhat is the model for floral induction by day-lengthSolutionB.pdf
What is the model for floral induction by day-lengthSolutionB.pdf
 
What is the difference between a semi-permeable and selectively perm.pdf
What is the difference between a semi-permeable and selectively perm.pdfWhat is the difference between a semi-permeable and selectively perm.pdf
What is the difference between a semi-permeable and selectively perm.pdf
 
what did Linnaeus contribute to taxonomySolutionThe classifica.pdf
what did Linnaeus contribute to taxonomySolutionThe classifica.pdfwhat did Linnaeus contribute to taxonomySolutionThe classifica.pdf
what did Linnaeus contribute to taxonomySolutionThe classifica.pdf
 
We are interested in whether the proportions of female suicide victim.pdf
We are interested in whether the proportions of female suicide victim.pdfWe are interested in whether the proportions of female suicide victim.pdf
We are interested in whether the proportions of female suicide victim.pdf
 
True or false Fruits attract animals that act as pollinators T.pdf
True or false Fruits attract animals that act as pollinators T.pdfTrue or false Fruits attract animals that act as pollinators T.pdf
True or false Fruits attract animals that act as pollinators T.pdf
 
the observed locations of integrated retroviral proviruses within ho.pdf
the observed locations of integrated retroviral proviruses within ho.pdfthe observed locations of integrated retroviral proviruses within ho.pdf
the observed locations of integrated retroviral proviruses within ho.pdf
 
The general name for something that binds to a protein is Select one.pdf
The general name for something that binds to a protein is  Select one.pdfThe general name for something that binds to a protein is  Select one.pdf
The general name for something that binds to a protein is Select one.pdf
 
serial communication, parallel communication, SPI and ADCs. Write .pdf
serial communication, parallel communication, SPI and ADCs. Write .pdfserial communication, parallel communication, SPI and ADCs. Write .pdf
serial communication, parallel communication, SPI and ADCs. Write .pdf
 
Suppose that a heap stores 210 elements. What is its height (show w.pdf
Suppose that a heap stores 210 elements. What is its height (show w.pdfSuppose that a heap stores 210 elements. What is its height (show w.pdf
Suppose that a heap stores 210 elements. What is its height (show w.pdf
 
Oxfam used its existing opt-in e-mail list only for this campaign; i.pdf
Oxfam used its existing opt-in e-mail list only for this campaign; i.pdfOxfam used its existing opt-in e-mail list only for this campaign; i.pdf
Oxfam used its existing opt-in e-mail list only for this campaign; i.pdf
 
Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdf
 
JUST DO QUESTION 4 1. When you are preparing a budget where could yo.pdf
JUST DO QUESTION 4 1. When you are preparing a budget where could yo.pdfJUST DO QUESTION 4 1. When you are preparing a budget where could yo.pdf
JUST DO QUESTION 4 1. When you are preparing a budget where could yo.pdf
 
In the paramyxoviruses, cleavage of the F0 protein into two subunits .pdf
In the paramyxoviruses, cleavage of the F0 protein into two subunits .pdfIn the paramyxoviruses, cleavage of the F0 protein into two subunits .pdf
In the paramyxoviruses, cleavage of the F0 protein into two subunits .pdf
 
Information about dengue fever is provided on the following pages. A.pdf
Information about dengue fever is provided on the following pages. A.pdfInformation about dengue fever is provided on the following pages. A.pdf
Information about dengue fever is provided on the following pages. A.pdf
 
A toothcomb, rhinarium or moist nose, and vertical clinging and leapi.pdf
A toothcomb, rhinarium or moist nose, and vertical clinging and leapi.pdfA toothcomb, rhinarium or moist nose, and vertical clinging and leapi.pdf
A toothcomb, rhinarium or moist nose, and vertical clinging and leapi.pdf
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 

The first part of the assignment involves creating very basic GUI co.pdf

  • 1. The first part of the assignment involves creating very basic GUI controls: a frame, panel, and slider. Create a JFrame. Add a title to the frame called Flight Reservation. Set the frame size to 475 by 500 pixels. Create a JPanel inside of the frame. You will be adding all of your UI components to this JPanel. [6 pts] Inside of the panel, create a label that says "Choose Color." Right below it, make a slider that changes the background color of the panel when the slider is moved to a particular color. The slider values should be RGB color values from 0 to 255 (or black to white). Assume that the RGB values for red, green, and blue are the same value - for instance: (240, 240, 240). The slider label's text should be replaced with the RGB value that the slider is currently on. [8 pts] Q2: Add functionality to search for an Itinerary. Create labels and text fields that allow the user to enter an airline, a source airport, and a destination airport, as well as the departure time and the arrival time to search for one or more available flights in an Itinerary. Also, create a ComboBox that will allow the user to select from a list of flight Itineraries. Each item in the ComboBox represents an Itinerary element, e.g. the first comboBoxelement is the first Itinerary in the array. [15 pts] Make sure all text fields have error checking and exception handling for invalid input. For example, if the user enters an integer as a departure time instead of a String (ie 1200 instead of 12:00 PM), a JOptionPane error message should appear stating, "Incorrect format for departure time." If the airline they entered is not in the Airline enum, then the option pane should say, "Airline unavailable. Please choose a different airline." If the airport they entered is not in the Airport enum, then the option pane should say, "Unknown city." Make sure the times are in hh:mm format. [8 pts] Q3: Create a button that says Search and a button that says View. When the user clicks Search, the combobox will get populated. When the user clicks View, if all the fields are filled out and have valid input, a JOptionPane with a message dialog should appear stating, "Flight search successful!" The frame should open a new JFrame with the title, "Flight Information," and a size of 475 by 500 pixels. This frame has the flight information displayed in a JTextArea. [6 pts] Q4: On the Flight Information frame, you will need to display information for each Flight in the Itinerary [7 points]: Airline: Display the airline Model: The model of the airplane should be generated from the Plane object inside of the Flight class. Departure Airport: Display the source airport Departure City: Display the departure city based on the departure airport (use the
  • 2. getAirportCity() method you implemented in the Unit 3 assignment to get the airport city) Destination Airport: Display the destination airport Destination City: Display the destination city based on the destination airport (use the getAirportCity() method again) Departure Time: Display the departure time Arrival Time: Display the arrival time Flight Number: A flight number should be selected based on the airline, followed by the Flight's number. Cost: Display the total cost, which should be computed by the Itinerary object. Solution I have given you the sample codes with inline commands. The code shown below is for the question number 1 and the remaining answers you can do in similar manner. create panel for each module and add every module into the frame. Pannel layout can be decided by setting the layout property eg: " panel.setLayout(new GridLayout(6, 2, 15, 0));" For better understanding please split all the classes into separate files. void java.awt.Window.pack() method packs the panel properly into the frame eg:frame.pack(“) it avoids missing the panel elements from the frame ChangeListner extends event Listener so that it capture the changes in the slider and immediate effect can be seen in the panel import java.awt.BorderLayout; import java.awt.Canvas; import java.awt.Color; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; public class test extends JFrame { public test() {
  • 3. JFrame frame = new JFrame("JFrame"); frame.setTitle("Flight Reservation"); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); panel.add(new ColourPick()); frame.add(panel); frame.setSize(475, 500); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); // add this code for packing the panel inside frame frame.pack(); } public static void main(String arg[]) { new test(); } } class ColourPick extends JPanel { DrawingCanvas canvas = new DrawingCanvas(); JLabel rgbValue = new JLabel(""); JSlider sliderR, sliderG, sliderB, sliderH, sliderS, sliderBr, sliderAlpha; public ColourPick() { sliderR = getSlider(0, 255, 0, 50, 5); sliderG = getSlider(0, 255, 0, 50, 5); sliderB = getSlider(0, 255, 0, 50, 5); sliderH = getSlider(0, 10, 0, 5, 1); sliderS = getSlider(0, 10, 0, 5, 1); sliderBr = getSlider(0, 10, 0, 5, 1); sliderAlpha = getSlider(0, 255, 255, 50, 5); JPanel panel = new JPanel(); JLabel label = new JLabel("Choose Color"); // add the panel size here according to your needs
  • 4. panel.setLayout(new GridLayout(6, 2, 15, 0)); panel.add(label); panel.add(new JLabel("R-G-B Sliders (0 - 255)")); panel.add(new JLabel("H-S-B Sliders (ex-1)")); panel.add(sliderR); panel.add(sliderH); panel.add(sliderG); panel.add(sliderS); panel.add(sliderB); panel.add(sliderBr); panel.add(new JLabel("Alpha Adjustment (0 - 255): ", JLabel.RIGHT)); panel.add(sliderAlpha); panel.add(new JLabel("RGB Value: ", JLabel.RIGHT)); rgbValue.setBackground(Color.white); rgbValue.setForeground(Color.black); rgbValue.setOpaque(true); panel.add(rgbValue); add(panel, BorderLayout.SOUTH); add(canvas); } public JSlider getSlider(int min, int max, int init, int mjrTkSp, int mnrTkSp) { JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, init); slider.setPaintTicks(true); slider.setMajorTickSpacing(mjrTkSp); slider.setMinorTickSpacing(mnrTkSp); slider.setPaintLabels(true); slider.addChangeListener(new SliderListener()); return slider; } class DrawingCanvas extends Canvas { Color color; int redValue, greenValue, blueValue; int alphaValue = 255; float[] hsbValues = new float[3]; public DrawingCanvas() {
  • 5. setSize(350, 350); color = new Color(0, 0, 0); setBackgroundColor(); } public void setBackgroundColor() { color = new Color(redValue, greenValue, blueValue, alphaValue); setBackground(color); } } class SliderListener implements ChangeListener { public void stateChanged(ChangeEvent e) { JSlider slider = (JSlider) e.getSource(); if (slider == sliderAlpha) { canvas.alphaValue = slider.getValue(); canvas.setBackgroundColor(); } else if (slider == sliderR) { canvas.redValue = slider.getValue(); displayRGBColor(); } else if (slider == sliderG) { canvas.greenValue = slider.getValue(); displayRGBColor(); } else if (slider == sliderB) { canvas.blueValue = slider.getValue(); displayRGBColor(); } else if (slider == sliderH) { canvas.hsbValues[0] = (float) (slider.getValue() * 0.1); displayHSBColor(); } else if (slider == sliderS) { canvas.hsbValues[1] = (float) (slider.getValue() * 0.1); displayHSBColor(); } else if (slider == sliderBr) { canvas.hsbValues[2] = (float) (slider.getValue() * 0.1); displayHSBColor(); } canvas.repaint(); }
  • 6. public void displayHSBColor() { canvas.color = Color.getHSBColor(canvas.hsbValues[0], canvas.hsbValues[1], canvas.hsbValues[2]); canvas.redValue = canvas.color.getRed(); canvas.greenValue = canvas.color.getGreen(); canvas.blueValue = canvas.color.getBlue(); sliderR.setValue(canvas.redValue); sliderG.setValue(canvas.greenValue); sliderB.setValue(canvas.blueValue); canvas.color = new Color(canvas.redValue, canvas.greenValue, canvas.blueValue, canvas.alphaValue); canvas.setBackground(canvas.color); } public void displayRGBColor() { canvas.setBackgroundColor(); Color.RGBtoHSB(canvas.redValue, canvas.greenValue, canvas.blueValue,canvas.hsbValues); sliderH.setValue((int) (canvas.hsbValues[0] * 10)); sliderS.setValue((int) (canvas.hsbValues[1] * 10)); sliderBr.setValue((int) (canvas.hsbValues[2] * 10)); rgbValue.setText(Integer.toString(canvas.color.getRGB() & 0xffffff, 16)); } } }