Java - Adding Event Handling & Application Exception Handling

profileBearbear

Class files in zip.

 

 

This part we will implement the event handling methods for our UI windows and top level menu.  Each input window should have, at a minimum, 3 buttons to clear the input, save the input, and close the window.  All three buttons should have an event handling method attached to them.  Make sure that the close button doesn't close the application!

The help about window should have a close button with an event handling method.

In addition, all of the menu items should have an event handling method that opens the window when selected.

The choice of whether you will implement event handling via the Netbeans Event tab, or writing your own event handling methods, is up to you.

In the event that you don't get all the buttons and menu items event handling methods implemented, you should disable that menu item or event.  If a button or menu item is clicked and nothing happens, that is an error in your code. 

Note that you have 2 weeks to finish this assignment and next week's assignment will overlap this one.  However, if you get it done earlier than the deadline, don't wait to hand it in. This assignment is a long one but shouldn't be too difficult if you have all of the base classes and the data container, implemented.

Event Handling Detail - An Example:

Implementing event handling for adding a student

1) Retrieve all the data from the input window using the getText method of the input fields

2) Create a Student object using an overloaded constructor to set the values of the data members or use the set methods, of the Student class.

3) Store the student in the array list in the data container

In order to store the student in the data container, you will have to pass the data container or the data container student list, to the constructor of the add student window and create a local copy of it as you can't modify the action performed method to take the data container as an argument.

 

For this part, we are going to modify the UI classes to throw exceptions on the following conditions:
1) When the Save button is clicked in either the Student or Faculty Add function, test for an empty name and SSN fields.  If the name or SSN field is empty, throw a NoDataException.  This will require you to write an exception class called "NoDataException".  To handle the exception, create a dialog box that will display when the exception is thrown, informing the user that either the name field or the SSN field, is empty. Don't allow the user to continue the save operation until these fields are filled in.   A dialog box should only have an Okay button to close the dialog box.

2) Test for an empty classroom number when the user clicks the Save button in the Classroom add window. If a classroom number field is empty, throw a NoRoomSpecifiedException.  This will require you to write an exception class called "NoRoomSpecifiedException".   If this exception is thrown, display a dialog box informing the user that no classroom number was specified and set a default classroom number of 100. NOTE: As you can see, we are not implementing exception handling for all fields in all classes.

  • 10 years ago
  • 40
Answer(1)

Purchase the answer to view it

blurred-text
  • attachment
    williamstearman_java301.zip
Bids(1)