Created
March 16, 2014 00:10
-
-
Save anonymous/9576038 to your computer and use it in GitHub Desktop.
Airline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package userInterface; | |
import javax.swing.*; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class AboutInfo { | |
public AboutInfo(JFrame parent) | |
{ | |
initComponents(parent); | |
} | |
private void initComponents(JFrame parent) | |
{ | |
JOptionPane.showMessageDialog(parent, "Airline Reservation System\nAuthor: Karin Whiting\nSpring 2014", | |
"About", JOptionPane.INFORMATION_MESSAGE); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package userInterface; | |
import javax.swing.JPanel; | |
/** | |
* | |
* @author | |
*/ | |
public class AddAirline { | |
AddAirline(JPanel mainPane) { | |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package userInterface; | |
import javax.swing.JPanel; | |
import java.awt.*; | |
import javax.swing.JButton; | |
/** | |
* | |
* @author Nick | |
*/ | |
public class AddAirport { | |
private JPanel mainPane; | |
public AddAirport(JPanel mainPane){ | |
GridBagLayout gridBagLayout; | |
GridBagConstraints constraints; | |
JPanel buttonPane; | |
JPanel dataPane; | |
BorderLayout borderLayout; | |
JButton addBtn; | |
JButton canxBtn; | |
JLabel newAirport; | |
JLabel enterName; | |
JTextField airportName; | |
JLabel enterCity; | |
JTextField airportCity; | |
JLabel selectState; | |
JComboBox airportState; | |
JLabel enterCode; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package userInterface; | |
import javax.swing.JPanel; | |
/** | |
* | |
* @author | |
*/ | |
public class AddFlight { | |
AddFlight(JPanel mainPane) { | |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package airline; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class Airline { | |
private String airlineName; | |
private String airlineHubLocation; | |
private Flight flight; | |
/** | |
* @return the airlineName | |
*/ | |
public String getAirlineName() { | |
return airlineName; | |
} | |
/** | |
* @param airlineName the airlineName to set | |
*/ | |
public void setAirlineName(String airlineName) { | |
this.airlineName = airlineName; | |
} | |
/** | |
* @return the airlineHubLocation | |
*/ | |
public String getAirlineHubLocation() { | |
return airlineHubLocation; | |
} | |
/** | |
* @param airlineHubLocation the airlineHubLocation to set | |
*/ | |
public void setAirlineHubLocation(String airlineHubLocation) { | |
this.airlineHubLocation = airlineHubLocation; | |
} | |
/** | |
* @return the flight | |
*/ | |
public Flight getFlight() { | |
return flight; | |
} | |
/** | |
* @param flight the flight to set | |
*/ | |
public void setFlight(Flight flight) { | |
this.flight = flight; | |
} | |
// overrides default public void toString() | |
public String toString() { | |
String message = "\n" + airlineName + " offers \nFlight " + flight.getflightnumber() + " to " | |
+ flight.getDestinationLocation(); | |
return message; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is the main User Interface | |
*/ | |
package userInterface; | |
import java.awt.BorderLayout; | |
import java.awt.event.*; | |
import javax.swing.*; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class AirlineReservation { | |
private JFrame frame; | |
private JMenuBar menuBar; | |
private JPanel mainPane; | |
private JMenu fileMenu; | |
private JMenuItem addAirport; | |
private JMenuItem addAirline; | |
private JMenuItem addFlight; | |
private JMenuItem exit; | |
private JMenu bookMenu; | |
private JMenuItem bookFlight; | |
private JMenu aboutMenu; | |
private JMenuItem aboutInfo; | |
public AirlineReservation() | |
{ | |
initComponents(); | |
} | |
private void initComponents() | |
{ | |
BorderLayout layout = new BorderLayout(); | |
// Initialize the JFrame | |
frame = new JFrame("COP 3330 Airline Reservation System"); | |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
frame.setSize(600, 400); | |
frame.setLayout(layout); | |
// Initialize the JMenuBar and add to the JFrame | |
menuBar = new JMenuBar(); | |
frame.add(menuBar, BorderLayout.NORTH); | |
// Initialize the File menu and add the JMenuItems with action listener | |
fileMenu = new JMenu("File"); | |
fileMenu.setMnemonic('F'); | |
// Register the event handler | |
addAirport = new JMenuItem("Add Airport"); | |
addAirport.addActionListener(new FileMenuAction()); | |
addAirline = new JMenuItem("Add Airline"); | |
addAirline.addActionListener(new FileMenuAction()); | |
addFlight = new JMenuItem("Add Flight"); | |
addFlight.addActionListener(new FileMenuAction()); | |
exit = new JMenuItem("Exit"); | |
exit.addActionListener(new FileMenuAction()); | |
fileMenu.add(addAirport); | |
fileMenu.add(addAirline); | |
fileMenu.add(addFlight); | |
fileMenu.add(exit); | |
menuBar.add(fileMenu); | |
// Initialize the Book menu and add the JMenuItems with action listener | |
bookMenu = new JMenu("Book"); | |
bookMenu.setMnemonic('B'); | |
bookFlight = new JMenuItem("Flight Reservations"); | |
bookFlight.addActionListener(new BookMenuAction()); | |
bookMenu.add(bookFlight); | |
menuBar.add(bookMenu); | |
// Initialize the About menu and add the JMenuItems with action listener | |
aboutMenu = new JMenu("About"); | |
aboutMenu.setMnemonic('A'); | |
aboutInfo = new JMenuItem("About Application"); | |
aboutInfo.addActionListener(new AboutMenuAction()); | |
aboutMenu.add(aboutInfo); | |
menuBar.add(aboutMenu); | |
// This is where the individual classes are populated | |
mainPane = new JPanel(); | |
frame.setVisible(true); | |
frame.validate(); | |
frame.repaint(); | |
} | |
public void showFrame() { | |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. | |
} | |
// Private inner class for event handling | |
private class FileMenuAction implements ActionListener | |
{ | |
// Process the object events | |
public void actionPerformed(ActionEvent e) | |
{ | |
// Remove any previous content | |
mainPane.removeAll(); | |
// gets the text of the JMenuItem | |
if (e.getActionCommand() == "Exit") | |
{ | |
System.exit(0); | |
} | |
else if (e.getActionCommand() == "Add Airport") | |
{ | |
AddAirport addAirport = new AddAirport(mainPane); | |
//mainPane.add(addAirport); | |
//frame.add(addAirportPane); | |
frame.getContentPane().add(mainPane, BorderLayout.CENTER); | |
frame.validate(); | |
frame.repaint(); | |
frame.setVisible(true); | |
} | |
else if (e.getActionCommand() == "Add Airline") | |
{ | |
AddAirline addAirline = new AddAirline(mainPane); | |
frame.getContentPane().add(mainPane, BorderLayout.CENTER); | |
frame.validate(); | |
frame.repaint(); | |
frame.setVisible(true); | |
} | |
else if (e.getActionCommand() == "Add Flight") | |
{ | |
AddFlight addFlight = new AddFlight(mainPane); | |
frame.getContentPane().add(mainPane, BorderLayout.CENTER); | |
frame.validate();; | |
frame.setVisible(true); | |
} | |
} | |
} | |
private class BookMenuAction implements ActionListener | |
{ | |
public void actionPerformed(ActionEvent e) | |
{ | |
// Remove any previous content | |
mainPane.removeAll(); | |
if (e.getActionCommand().equalsIgnoreCase("Flight Reservations")) | |
{ | |
// Set the layout manager | |
BorderLayout layout = new BorderLayout(); | |
// Create the main panel for the JTabbedPane to be added to | |
mainPane.setLayout(layout); | |
// Add the main panel to the JFrame | |
frame.getContentPane().add(mainPane); | |
// Create the JTabbedPane | |
JTabbedPane tabs = new JTabbedPane(); | |
// Create the tabs | |
SearchFlight search = new SearchFlight(); | |
tabs.add("Search Flight", search); | |
SelectFlight select = new SelectFlight(); | |
tabs.add("Select Flight", select); | |
FlightPrice price = new FlightPrice(); | |
tabs.add("Flight Price", price); | |
BookTicket book = new BookTicket(); | |
tabs.add("Book Ticket", book); | |
Payment pay = new Payment(); | |
tabs.add("Payment", pay); | |
BookingSummary summary = new BookingSummary(); | |
tabs.add("Booking Summary", summary); | |
// Add the tabbed panel to the main panel | |
mainPane.add(tabs, BorderLayout.CENTER); | |
// Add the main panel to the frame | |
frame.add(mainPane, BorderLayout.CENTER); | |
frame.setVisible(true); | |
frame.validate(); | |
} | |
} | |
} | |
private class AboutMenuAction implements ActionListener | |
{ | |
public void actionPerformed(ActionEvent e) | |
{ | |
if (e.getActionCommand() == "About Application") | |
{ | |
AboutInfo about = new AboutInfo(frame); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package airportmain; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class Airplane { | |
private String airplaneType; | |
private int numberOfSeats; | |
private int weightLimit; | |
private int yearsInService; | |
/** | |
* @return the airplaneType | |
*/ | |
public String getAirplaneType() { | |
return airplaneType; | |
} | |
/** | |
* @param airplaneType the airplaneType to set | |
*/ | |
public void setAirplaneType(String airplaneType) { | |
this.airplaneType = airplaneType; | |
} | |
/** | |
* @return the numberOfSeats | |
*/ | |
public int getNumberOfSeats() { | |
return numberOfSeats; | |
} | |
/** | |
* @param numberOfSeats the numberOfSeats to set | |
*/ | |
public void setNumberOfSeats(int numberOfSeats) { | |
this.numberOfSeats = numberOfSeats; | |
} | |
/** | |
* @return the weightLimit | |
*/ | |
public int getWeightLimit() { | |
return weightLimit; | |
} | |
/** | |
* @param weightLimit the weightLimit to set | |
*/ | |
public void setWeightLimit(int weightLimit) { | |
this.weightLimit = weightLimit; | |
} | |
/** | |
* @return the yearsInService | |
*/ | |
public int getYearsInService() { | |
return yearsInService; | |
} | |
/** | |
* @param yearsInService the yearsInService to set | |
*/ | |
public void setYearsInService(int yearsInService) { | |
this.yearsInService = yearsInService; | |
} | |
public String toString() | |
{ | |
return ""; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package airline; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class Airport { | |
private String airportName; | |
private String airportCity; | |
private String airportState; | |
private String airportCode; | |
/** | |
* @return the airportName | |
*/ | |
public String getAirportName() { | |
return airportName; | |
} | |
/** | |
* @param airportName the airportName to set | |
*/ | |
public void setAirportName(String airportName) { | |
this.airportName = airportName; | |
} | |
/** | |
* @return the airportCity | |
*/ | |
public String getAirportCity() { | |
return airportCity; | |
} | |
/** | |
* @param airportCity the airportCity to set | |
*/ | |
public void setAirportCity(String airportCity) { | |
this.airportCity = airportCity; | |
} | |
/** | |
* @return the airportState | |
*/ | |
public String getAirportState() { | |
return airportState; | |
} | |
/** | |
* @param airportState the airportState to set | |
*/ | |
public void setAirportState(String airportState) { | |
this.airportState = airportState; | |
} | |
/** | |
* @return the airportCode | |
*/ | |
public String getAirportCode() { | |
return airportCode; | |
} | |
/** | |
* @param airportCode the airportCode to set | |
*/ | |
public void setAirportCode(String airportCode) { | |
this.airportCode = airportCode; | |
} | |
public String toString() { | |
return airportName + " in " + getAirportCity() + ", " + getAirportState() + " has"; | |
} | |
public Airport(String inName, String inCity, String inState, String inCode) | |
{ | |
airportName = inName; | |
airportCity = inCity; | |
airportState = inState; | |
airportCode = inCode; | |
} | |
public Airport() | |
{ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package airline; | |
import java.util.Date; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class Flight { | |
private int flightNumber; | |
private String originatingLocation; | |
private String destinationLocation; | |
private Date departure; | |
private Date arrival; | |
private String airplaneType; | |
/** | |
* @return the flightNumber | |
*/ | |
public int getflightnumber() { | |
return flightNumber; | |
} | |
/** | |
* @param flightNumber the flightNumber to set | |
*/ | |
public void setFlightNumber(int flightNumber) { | |
this.flightNumber = flightNumber; | |
} | |
/** | |
* @return the originatingLocation | |
*/ | |
public String getOriginatingLocation() { | |
return originatingLocation; | |
} | |
/** | |
* @param originatingLocation the originatingLocation to set | |
*/ | |
public void setOriginatingLocation(String originatingLocation) { | |
this.originatingLocation = originatingLocation; | |
} | |
/** | |
* @return the destinationLocation | |
*/ | |
public String getDestinationLocation() { | |
return destinationLocation; | |
} | |
/** | |
* @param destinationLocation the destinationLocation to set | |
*/ | |
public void setDestinationLocation(String destinationLocation) { | |
this.destinationLocation = destinationLocation; | |
} | |
/** | |
* @return the departure | |
*/ | |
public Date getDeparture() { | |
return departure; | |
} | |
/** | |
* @param departure the departure to set | |
*/ | |
public void setDeparture(Date departure) { | |
this.departure = departure; | |
} | |
/** | |
* @return the arrival | |
*/ | |
public Date getArrival() { | |
return arrival; | |
} | |
/** | |
* @param arrival the arrival to set | |
*/ | |
public void setArrival(Date arrival) { | |
this.arrival = arrival; | |
} | |
/** | |
* @return the airplaneType | |
*/ | |
public String getAirplaneType() { | |
return airplaneType; | |
} | |
/** | |
* @param airplaneType the airplaneType to set | |
*/ | |
public void setAirplaneType(String airplaneType) { | |
this.airplaneType = airplaneType; | |
} | |
public Flight( int inFlightNumber) | |
{ | |
flightNumber = inFlightNumber; | |
} | |
public String toString() | |
{ | |
// return flightNumber + originatingLocation + destinationLocation + departure + arrival + airplaneType; | |
return ""; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package userInterface; | |
import javax.swing.*; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class BookingSummary extends JPanel { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package userInterface; | |
import javax.swing.*; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class BookTicket extends JPanel { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package airline; | |
import java.util.Date; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class Flight { | |
private int flightNumber; | |
private String originatingLocation; | |
private String destinationLocation; | |
private Date departure; | |
private Date arrival; | |
private String airplaneType; | |
/** | |
* @return the flightNumber | |
*/ | |
public int getflightnumber() { | |
return flightNumber; | |
} | |
/** | |
* @param flightNumber the flightNumber to set | |
*/ | |
public void setFlightNumber(int flightNumber) { | |
this.flightNumber = flightNumber; | |
} | |
/** | |
* @return the originatingLocation | |
*/ | |
public String getOriginatingLocation() { | |
return originatingLocation; | |
} | |
/** | |
* @param originatingLocation the originatingLocation to set | |
*/ | |
public void setOriginatingLocation(String originatingLocation) { | |
this.originatingLocation = originatingLocation; | |
} | |
/** | |
* @return the destinationLocation | |
*/ | |
public String getDestinationLocation() { | |
return destinationLocation; | |
} | |
/** | |
* @param destinationLocation the destinationLocation to set | |
*/ | |
public void setDestinationLocation(String destinationLocation) { | |
this.destinationLocation = destinationLocation; | |
} | |
/** | |
* @return the departure | |
*/ | |
public Date getDeparture() { | |
return departure; | |
} | |
/** | |
* @param departure the departure to set | |
*/ | |
public void setDeparture(Date departure) { | |
this.departure = departure; | |
} | |
/** | |
* @return the arrival | |
*/ | |
public Date getArrival() { | |
return arrival; | |
} | |
/** | |
* @param arrival the arrival to set | |
*/ | |
public void setArrival(Date arrival) { | |
this.arrival = arrival; | |
} | |
/** | |
* @return the airplaneType | |
*/ | |
public String getAirplaneType() { | |
return airplaneType; | |
} | |
/** | |
* @param airplaneType the airplaneType to set | |
*/ | |
public void setAirplaneType(String airplaneType) { | |
this.airplaneType = airplaneType; | |
} | |
public Flight( int inFlightNumber) | |
{ | |
flightNumber = inFlightNumber; | |
} | |
public String toString() | |
{ | |
// return flightNumber + originatingLocation + destinationLocation + departure + arrival + airplaneType; | |
return ""; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package userInterface; | |
import javax.swing.*; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class FlightPrice extends JPanel { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package airportmain; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class Passenger { | |
private String firstName; | |
private String lastName; | |
private String postalAddress; | |
private String city; | |
private String state; | |
private String zipCode; | |
private String telephoneNumber; | |
private String passengerIdentification; | |
/** | |
* @return the firstName | |
*/ | |
public String getFirstName() { | |
return firstName; | |
} | |
/** | |
* @param firstName the firstName to set | |
*/ | |
public void setFirstName(String firstName) { | |
this.firstName = firstName; | |
} | |
/** | |
* @return the lastName | |
*/ | |
public String getLastName() { | |
return lastName; | |
} | |
/** | |
* @param lastName the lastName to set | |
*/ | |
public void setLastName(String lastName) { | |
this.lastName = lastName; | |
} | |
/** | |
* @return the postalAddress | |
*/ | |
public String getPostalAddress() { | |
return postalAddress; | |
} | |
/** | |
* @param postalAddress the postalAddress to set | |
*/ | |
public void setPostalAddress(String postalAddress) { | |
this.postalAddress = postalAddress; | |
} | |
/** | |
* @return the city | |
*/ | |
public String getCity() { | |
return city; | |
} | |
/** | |
* @param city the city to set | |
*/ | |
public void setCity(String city) { | |
this.city = city; | |
} | |
/** | |
* @return the state | |
*/ | |
public String getState() { | |
return state; | |
} | |
/** | |
* @param state the state to set | |
*/ | |
public void setState(String state) { | |
this.state = state; | |
} | |
/** | |
* @return the zipCode | |
*/ | |
public String getZipCode() { | |
return zipCode; | |
} | |
/** | |
* @param zipCode the zipCode to set | |
*/ | |
public void setZipCode(String zipCode) { | |
this.zipCode = zipCode; | |
} | |
/** | |
* @return the telephoneNumber | |
*/ | |
public String getTelephoneNumber() { | |
return telephoneNumber; | |
} | |
/** | |
* @param telephoneNumber the telephoneNumber to set | |
*/ | |
public void setTelephoneNumber(String telephoneNumber) { | |
this.telephoneNumber = telephoneNumber; | |
} | |
/** | |
* @return the passengerIdentification | |
*/ | |
public String getPassengerIdentification() { | |
return passengerIdentification; | |
} | |
/** | |
* @param passengerIdentification the passengerIdentification to set | |
*/ | |
public void setPassengerIdentification(String passengerIdentification) { | |
this.passengerIdentification = passengerIdentification; | |
} | |
public String toString() | |
{ | |
return ""; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package userInterface; | |
import javax.swing.*; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class Payment extends JPanel { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package userInterface; | |
import java.awt.Component; | |
import java.awt.Container; | |
import java.awt.Dimension; | |
import java.awt.GridBagLayout; | |
import java.awt.GridBagConstraints; | |
import javax.swing.*; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class SearchFlight extends JPanel { | |
private JRadioButton oneWay; | |
private JRadioButton roundTrip; | |
private ButtonGroup buttonGroup; | |
private JLabel fromDestLbl; | |
private JComboBox fromDestCb; | |
private JLabel toDestLbl; | |
private JComboBox toDestCb; | |
private JLabel departLbl; | |
private JComboBox departMonth; | |
private JComboBox departDay; | |
private JTextField departYear; | |
private JLabel arriveLbl; | |
private JComboBox arriveMonth; | |
private JComboBox arriveDay; | |
private JTextField arriveYear; | |
private JLabel adultLbl; | |
private JComboBox adultCb; | |
private JLabel childLbl; | |
private JComboBox childCb; | |
private JLabel infantLbl; | |
private JComboBox infantCb; | |
private JButton searchBtn; | |
private JButton canxBtn; | |
private GridBagLayout gridBagLayout; | |
private GridBagConstraints constraints; | |
public SearchFlight() | |
{ | |
initComponents(); | |
} | |
private void initComponents() | |
{ | |
gridBagLayout = new GridBagLayout(); | |
constraints = new GridBagConstraints(); | |
this.setLayout(gridBagLayout); | |
oneWay = new JRadioButton("One Way"); | |
roundTrip = new JRadioButton("Round Trip"); | |
buttonGroup = new ButtonGroup(); | |
buttonGroup.add(oneWay); | |
buttonGroup.add(roundTrip); | |
this.addComponent(0, 0, 1, 1, this, oneWay); | |
this.addComponent(1, 0, 1, 1, this, roundTrip); | |
fromDestLbl = new JLabel("From"); | |
fromDestLbl.setPreferredSize(new Dimension(50, 25)); | |
fromDestCb = new JComboBox(); | |
fromDestCb.setPreferredSize(new Dimension(200, 25)); | |
this.addComponent(0, 1, 1, 1, this, fromDestLbl); | |
this.addComponent(1, 1, 3, 1, this, fromDestCb); | |
toDestLbl = new JLabel("To"); | |
toDestLbl.setPreferredSize(new Dimension(50, 25)); | |
toDestCb = new JComboBox(); | |
toDestCb.setPreferredSize(new Dimension(200, 25)); | |
this.addComponent(0, 2, 1, 1, this, toDestLbl); | |
this.addComponent(1, 2, 3, 1, this, toDestCb); | |
departLbl = new JLabel("Depart"); | |
departLbl.setPreferredSize(new Dimension(50, 25)); | |
departMonth = new JComboBox(); | |
departMonth.setPreferredSize(new Dimension(50, 25)); | |
departDay = new JComboBox(); | |
departDay.setPreferredSize(new Dimension(50, 25)); | |
departYear = new JTextField(); | |
departYear.setPreferredSize(new Dimension(50, 25)); | |
this.addComponent(0, 3, 1, 1, this, departLbl); | |
this.addComponent(1, 3, 1, 1, this, departMonth); | |
this.addComponent(2, 3, 1, 1, this, departDay); | |
this.addComponent(3, 3, 1, 1, this, departYear); | |
arriveLbl = new JLabel("Arrive"); | |
arriveLbl.setPreferredSize(new Dimension(50, 25)); | |
arriveMonth = new JComboBox(); | |
arriveMonth.setPreferredSize(new Dimension(50, 25)); | |
arriveDay = new JComboBox(); | |
arriveDay.setPreferredSize(new Dimension(50, 25)); | |
arriveYear = new JTextField(); | |
arriveYear.setPreferredSize(new Dimension(50, 25)); | |
this.addComponent(0, 4, 1, 1, this, arriveLbl); | |
this.addComponent(1, 4, 1, 1, this, arriveMonth); | |
this.addComponent(2, 4, 1, 1, this, arriveDay); | |
this.addComponent(3, 4, 1, 1, this, arriveYear); | |
adultLbl = new JLabel("Adult"); | |
adultLbl.setPreferredSize(new Dimension(50, 25)); | |
adultCb = new JComboBox(); | |
adultCb.setPreferredSize(new Dimension(50, 25)); | |
this.addComponent(0, 5, 1, 1, this, adultLbl); | |
this.addComponent(1, 5, 1, 1, this, adultCb); | |
childLbl = new JLabel("Child"); | |
childLbl.setPreferredSize(new Dimension(50, 25)); | |
childCb = new JComboBox(); | |
childCb.setPreferredSize(new Dimension(50, 25)); | |
this.addComponent(0, 6, 1, 1, this, childLbl); | |
this.addComponent(1, 6, 1, 1, this, childCb); | |
infantLbl = new JLabel("Infant"); | |
infantLbl.setPreferredSize(new Dimension(50, 25)); | |
infantCb = new JComboBox(); | |
infantCb.setPreferredSize(new Dimension(50, 25)); | |
this.addComponent(0, 7, 1, 1, this, infantLbl); | |
this.addComponent(1, 7, 1, 1, this, infantCb); | |
searchBtn = new JButton("Search Flights"); | |
searchBtn.setPreferredSize(new Dimension(125, 25)); | |
this.addComponent(0, 8, 2, 1, this, searchBtn); | |
canxBtn = new JButton("Cancel"); | |
canxBtn.setPreferredSize(new Dimension(125, 25)); | |
this.addComponent(2, 8, 2, 1, this, canxBtn); | |
} | |
// X is the column | |
// Y is the row | |
// W is the width in cells | |
// H is the height in cells | |
// aContainer is the container the component is added to | |
// aComponent is the component being added to the container | |
private void addComponent( int x, int y, int w, int h, Container aContainer, Component aComponent ) | |
{ | |
constraints.gridx = x; | |
constraints.gridy = y; | |
constraints.gridwidth = w; | |
constraints.gridheight = h; | |
gridBagLayout.setConstraints( aComponent, constraints ); | |
aContainer.add( aComponent ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package userInterface; | |
import javax.swing.*; | |
/** | |
* | |
* @author kwhiting | |
*/ | |
public class SelectFlight extends JPanel { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment