Objectives

Students will be able to:

Task 5

Task A

A cool Java Swing component is a JOptionPane:

  • when it appears it offers the user buttons to click.
  • when a button is clicked, the box closes and an integer is returned to the calling program
  • we can process that value to decide what to do next

In your code, just before data is written to the file (or before the file is created), introduce a JOptionPane and create a variable to store the returned value eg:

int input = JOptionPane.showConfirmDialog(null, "Do you want to proceed?", "Confirmation Box",JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

Try to figure out what value is being returned if you click YES and what value is being returned when you click NO.

Use that knowledge to code the expected behaviour outlined by the requirement above.

helper video

Task B

Clearing fields

After data has successfully been written to the file, a method clearFields is called. This method clears the three text boxes so that the user can register another member without having to delete already-recorded data. It should also get the identity checkbox to unchecked, and empty the registration number label.

Testing

These forms of testing were described at the top of this page. Do you think you could give a definition to each one?!

  1. whitebox
  2. blackbox
  3. alpha
  4. beta

Tags

alpha testing beta testing whitebox testing blackbox testing JOptionPane


SUBSCRIBE

Join my mailing list to receive updates on the latest blog posts and other things.