/** * Supplied GUI code for ass2, coit11222, T2 2018 * You are going to complete the code for each required method * **/ import java.awt.FlowLayout; import java.awt.Font; import...

I face some problems in this programming I have done many parts, please just fix the problems in uploaded GUI programme and please also see the assignment pdf file, also do the report including the sucessfull screenshots.


/** * Supplied GUI code for ass2, coit11222, T2 2018 * You are going to complete the code for each required method * **/ import java.awt.FlowLayout; import java.awt.Font; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.*; // class definition public class CarHireGUI extends JFrame implements ActionListener { //GUI components building private JLabel nameLabel=new JLabel("Customer name"); private JLabel licenseLabel=new JLabel("License number"); private JLabel daysLabel=new JLabel("Hired days"); private JTextField nameField=new JTextField(28); private JTextField licenseField=new JTextField(14); private JTextField daysField=new JTextField(7); private JButton enterButton=new JButton("Enter"); // private JButton displayButton=new JButton("Display"); private JButton searchButton= new JButton("Search"); private JButton exitButton=new JButton("Exit"); private JTextArea textArea=new JTextArea(16,38); private JScrollPane scrollPane; // scroll pane for the text area private final int MAX_NUM = 10; private CarHire[] carHireArray = new CarHire[MAX_NUM]; private int currentCustomer = 0; private static final int FRAME_WIDTH = 490;// window size private static final int FRAME_HEIGHT = 430; //Constructs public CarHireGUI() { super(" XYZ Car Hire App "); setLayout(new FlowLayout()); //FlowLayout add(nameLabel); //add componts to JFrame add(nameField); add(licenseLabel); add(licenseField); add(daysLabel); add(daysField); scrollPane = new JScrollPane(textArea); // add text area to the scroll pane scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); // just need vertical scrolling add(scrollPane); add(enterButton); add(displayButton); add(searchButton); add(exitButton); add(textArea); enterButton.addActionListener(this); //listen to event displayButton.addActionListener(this); searchButton.addActionListener(this); exitButton.addActionListener(this); } //event handling method public void actionPerformed(ActionEvent e) { String actionString=e.getActionCommand(); switch(actionString) { case "Enter": enterData(); break; case "Display": displayAll(); break; case "Search": search(); break; case "Exit": exit(); break; default: System.out.println("invalid input"); } } // process input data public void enterData() { if (nameField.getText().compareTo("") == 0) { JOptionPane.showMessageDialog(null,"You must enter a customer name","XYZ Car Hire App",JOptionPane.ERROR_MESSAGE); return; } if (licenseField.getText().compareTo("") == 0) { JOptionPane.showMessageDialog(null,"You must enter a license number","XYZ Car Hire App",JOptionPane.ERROR_MESSAGE); return; } if (daysField.getText().compareTo("") == 0) { JOptionPane.showMessageDialog(null,"You must enter days hired","XYZ Car Hire App",JOptionPane.ERROR_MESSAGE); return; } String customerName = nameField.getText(); String licenseNumber = licenseField.getText(); int calculateRental = calculateRental.getText(); } // Display all bookings public void displayAll() { if (currentCustomer == 0) { JOptionPane.showMessageDialog(null, "No customers entered", "XYZ Car Hire App", JOptionPane.ERROR_MESSAGE); // displayTextArea.setText(""); return; displayHeading(); for(int count=0;count
Sep 28, 2020COIT11222Central Queensland University
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here