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
- During the lab, if you know what you are doing, and can help your neighbour, then help them. If you need help, ask us or your neighbour.
Setup and Submission
- Login to a lab system; cd to your local copy of your repo OR clone
it again (see lab01);
git pullto get an up-to-date copy of the repo. The folderlab06should be there. - Open the lab06 IntelliJ project
- The lab06 project should now show up in your sidebar. Work with the files in the project
- As you work on the lab, add/stage, commit, and push your changes like how you did it in Lab 1. You should use the terminal for the Git commands rather than using the git features built into IntelliJ because we want you to learn to be able to use Git even when not using IntelliJ, and lab06 is NOT a git repo, it is in a git repo!
- SUBMISSION: Remember to commit and push your project at the end of your lab so we can see the most updated version of your lab work.
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.
- 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.
- 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