Course web page: Introduction to Computer Science for majors II James Tam Return to the course web page

CPSC 219: Mini-Assignment #5

Due Friday April 7 at 4 PM

Text only connections such as Putty won't allow you to run programs that employ graphical user interfaces. If you have been working at home to complete assignments but haven't installed JDK on your computer then you might want to either install a free file transfer program such as Filezilla (server name:, port: 22) or perhaps a cloud based storage system such as To run your programs you can run 'Java' locally using JRE (unlike the JDK which includes the compiler you don't have to worry about setting the 'path'). Open up a command line on your home computer 'cmd' and use it to navigate to where you have your GUI code on your CPSC account. (. When you type 'java Driver' (or whatever the name of starting class is) your GUI will be run locally on your computer.

New Concepts to be applied for the assignment


Figure 1: Program initially run, JFrame contains a JButton with default text

Figure 2: Button pressed: the text of the button changes to a non-default value

Figure 3: Button pressed: a new  JFrame popup (containing the same non-default text from the button) appears for each press

Figure 4: Clicking on the close window control (top right of the JFrame) will 'dispose' of the control (rather than default 'hide' behavior)

External libraries that can be used

Unlike the other assignments you will make extensive use of the pre-created Java libraries developed by Sun/Oracle for graphical components (e.g., java.awt., javax.swing), event handling (e.g., java.awt.event) .


Points to keep in mind:

  1. Due time: All assignments are due at 4 PM on the due dates listed on the course web page.  Late assignments or components of assignments will not be accepted for marking without approval for an extension beforehand. The latest versions of the files that you have submitted in D2L as of the due date is what will be marked.
  2. Extensions may be granted for reasonable cases by the course instructor with the receipt of the appropriate documentation (e.g., a doctor's note). Typical examples of reasonable cases for an extension include: illness or a death in the family. Cases where extensions will not be granted include situations that are typical of student life: having multiple due dates, work commitments etc. Tutorial instructors (TA's) will not be able to provide extension on their own and must receive permission from the course instructor first. (Note: Forgetting to hand your assignment or a component of your assignment in does not constitute a sufficient reason for handing your assignment late).
  3. Method of submission: You are to submit your assignment using D2L [help link]. Make sure that you [check the contents of your submitted files] (e.g., is the file okay or was it corrupted, is it the correct version etc.). It's your responsibility to do this! (Make sure that you submit your assignment with enough time before it comes due for you to do a check).
  4. Identifying information: All assignments should include contact information (full name and student ID number) at the very top of your program in the class where the 'main()' method resides. (Note other documentation is also required for most assignments).
  5. Collaboration: Assignments must reflect individual work; group work is not allowed in this class nor can you copy the work of others.  For more detailed information as to what constitutes academic misconduct (i.e., cheating) for this course please read the following [link].
  6. Execution: programs must run on the computer science network running Java 8.x. If you write you code in the lab and work remotely using a remote login program such as Putty or SSH then should already be using the correct version. If you choose to install Java on your own computer, then it is your responsibility to ensure that your program will run properly on the CPSC Linux computers. It's not recommended that you use an IDE for writing your programs but if you use one then make sure that you submit your program in the form of text ".java" file or files. If you only submit your byte code files (e.g. Driver.class) then you will not be awarded any credit.
  7. Use of pre-created Java libraries: unless otherwise told you are to write the code yourself and not use any pre-created functions from the Java libraries. For this assignment the usual acceptable functions include: System.out.print(), System.out.println(), the methods of the Console class and for some assignments the methods of the Random class. Look at the particular assignment description for a list of other classes that you are allowed to use and still get credit in an assignment submission.
  8. Style conventions, programming decomposition: the marking points from the previous assignment also apply to this assignment. The one blanket exception is the use of a static debugging flag (or flags) if you choose to implement multiple flags.

D2L configuration: