Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

In the reserveCarJButtonActionPerformed method I need to add a try block (which I've done).

In the reserveCarJButtonActionPerformed method I need to add a try block (which I've done).....But....Inside the try block, I need to create a FileReader by passing the reserveFile to ists constructor. Then, use this FileReader to intialize BufferedReader input. I've uploaded the code file I've worked on so far...as well as, pasted below.// Exercise 25.15: CarReservation.java// This application allows users to input their names and// reserve cars on various days.import java.awt.*;import java.awt.event.*;import java.io.*;import java.util.Date;import javax.swing.*;import javax.swing.event.*;public class CarReservation extends JFrame{// JLabel and JSpinner to display dateprivate JLabel selectDateJLabel;private JSpinner dateJSpinner;// JLabel and JTextField to display nameprivate JLabel nameJLabel;private JTextField nameJTextField;// JButton to reserve carprivate JButton reserveCarJButton;//create two instance variablesPrintWriter output;BufferedReader input; // no-argument constructorpublic CarReservation(){createUserInterface();}// create and position GUI componentspublic void createUserInterface(){// get content pane for attaching GUI componentsContainer contentPane = getContentPane();// enable explicit positioning of GUI componentscontentPane.setLayout( null );// set up selectDateJLabelselectDateJLabel = new JLabel();selectDateJLabel.setBounds( 16, 16, 96, 23 );selectDateJLabel.setText( "Select the date:" );contentPane.add( selectDateJLabel );// set up dateJSpinnerdateJSpinner = new JSpinner( new SpinnerDateModel() );dateJSpinner.setBounds( 16, 43, 250, 23 );dateJSpinner.setEditor( new JSpinner.DateEditor( dateJSpinner, "MM/dd/yyyy" ) ); contentPane.add( dateJSpinner );dateJSpinner.addChangeListener(new ChangeListener() // anonymous inner class{// event handler called when dateJSpinner is changedpublic void stateChanged( ChangeEvent event ){dateJSpinnerChanged( event );}} // end anonymous inner class// set up nameJLabelnameJLabel = new JLabel();nameJLabel.setBounds( 16, 70, 100, 23 );nameJLabel.setText( "Name: " );contentPane.add( nameJLabel );// set up nameJTextFieldnameJTextField = new JTextField();nameJTextField.setBounds( 16, 97, 250, 23 );contentPane.add( nameJTextField );// set up reserveCarJButtonreserveCarJButton = new JButton();reserveCarJButton.setBounds( 16, 130, 250, 23 );reserveCarJButton.setText( "Reserve Car" );contentPane.add( reserveCarJButton );reserveCarJButton.addActionListener(new ActionListener() // anonymous inner class{// event handler called when reserveCarJButton is clickedpublic void actionPerformed( ActionEvent event ){reserveCarJButtonActionPerformed( event );//create new File ObjectString reserveFile = "reservations.txt" try{File}}} // end anonymous inner class); // end call to addActionListener// set properties of application's windowsetTitle( "Car Reservation" ); // set title bar string// set window size// display window} // end method createUserInterface// write reservation to a fileprivate void reserveCarJButtonActionPerformed( ActionEvent event ){} // end method reserveCarJButtonActionPerformed// enable reserveCarJButtonprivate void dateJSpinnerChanged( ChangeEvent event ){reserveCarJButton.setEnabled( true );} // end method dateJSpinnerChanged// main methodpublic static void main( String[] args ){CarReservation application = new CarReservation();application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );} // end method main} // end class CarReservation/********************************************************************************** * programs or to the documentation contained in these books. The authors **** **************************************************************************/

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question