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: linux.cpsc.ucalgary.ca, port: 22) or
perhaps a cloud based storage system such as
www.dropbox.com. 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
- Implementing a simple graphical user interface with common GUI controls
(JButton, JFrame)
and event handlers (ActionListener).
Overview
- When the program runs it will create a JFrame
containing a JButton the latter with some
default text (Figure 1): worth 1 mark
- When the button is pressed two things will happen:
- The text of the button changes to a non-default value (Figure 2):
worth 1 mark
- Another JFrame window appears that
contains the same non-default text contained in the button (Figure 3):
worth 1 mark
- The close behavior for both (no credit if
you change one but not the other) JFrames
(triggered when the close window control is clicked: Figure 4) is changed
from hiding the window to the disposal of the control: worth 1 mark
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) .
Marking
-
Assignments will be marked by your tutorial instructor (the "Teaching
Assistant" or "TA"). When you have questions about marking this is the first
person that you should be directing your questions towards. If you still
have question after you have talked to your TA, then you can talk to your
course (lecture) instructor.
-
Unlike full assignments, min-assignments are
only marked on program functionality (above).
Points to keep in mind:
-
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.
-
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).
-
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).
-
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).
-
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].
-
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.
-
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.
-
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:
-
Multiple submissions are possible for each assignment: You can and should
submit many times before the due date. D2L will simply overwrite previous
submissions with newer ones.
-
Important!
Multiple files can be submitted for each assignment. I am allowing you to
submit multiple files for each assignment so you don't have to worry about
archiving/compressing multiple files using a utility such as zip. However,
this means that TAs will only mark the latest versions of each file
submitted via D2L. Even if the version of a document that you want marked
has been uploaded into D2L if it isn't the latest version then you will only
get marks for the latest version. (It's unfair to have the TAs check
versions or to remark assignments because marking is enough work as-is).