Lab 6 GUI Programming in Java

All work to be added, committed and pushed to the remote by 11:59PM on Sunday.
IMPORTANT: While you are in the lab, login in to a lab desktop, bring up chrome and visit this attendance app This will register your attendance in the lab. Make sure you have, at some point during the lab, logged in directly on a lab system (using the lab keyboard, monitor and mouse, no ssh!!).

Notes

Setup and Submission

GUI Programming

You might think that this is about GUI programming, really it is a way to trick you into learning about interfaces, inheritance (extends), and event driven programming.

You should refer to the Week 4/5 lectures for examples of GUI code using JavaFX.

  1. First, fix HiBye.java and HiByeEventHandler.java as described in the code. Remember, to fix this, you will need to modify the constructor for HiByeEventHandler.
  2. Create class PrimeTester inside the lab06 project. PrimeTester should launch the following GUI. Three different application screenshots are shown below.




    This consists of a TextField, a Button and another TextField. The second TextField is not editable (see the java api). For this example, copy HiBye.java to PrimeTester.java and copy HiByeEventHandler.java to PrimeTesterEventHandler.java. You will need to add a TextField!

    To parse an integer and catch errors, use something like the following ...

    try { int n=Integer.parseInt(this.question.getText()); // n is a valid integer in here... } catch(NumberFormatException nfe){ System.out.println("invalid number"); }

    Use the following isPrime method.

    private static boolean isPrime(int n){ if(n<2)return false; for(int i=2;i<n;i++){ if(n%i == 0) return false; } return true; }