Computer Science Courses
Related sites
HW 7 |
To start writing simple graphics and GUI programs to learn the basic of event-driven programming, and have a a first experience of JavaFX RIA framework.
Read parts of to help yourself with this lab exercises.
Define all programs be part of the module hw7
.
Using the IntelliJ IDEA IDE (or Netbeans, or Eclipse), create a JavaFX program called ColouredShapes.java
, which displays a few simple shapes like square, triangle, circle and so on, all having different colours.
Then (after succeeding in the previous step) attach an event handler to each of the shape to detect events when the mouse moves into the region occupied by the shape. By using the original Assignment Two code as example, you will have to set onMouseMovedProperty
of a shape object to an EventHandler〈MouseEvent〉
and implement the handle(MouseEvent e)
method to generate a desired effect when the mouse enters the shape region. Consider the following effects:
stdout
Create another program, called SimpleTransitions.java
.which displays a simple shape with colour and then does one of the followingwhen an event is generated:
When (if) all of the above transition effects work as described,try to combine them so a transition involves movement (shift and rotation),shape and colour changes. I leave it to you to choose the actual combinationand the event which triggers the transition: It can be a mouse event, or a keyboard event, or you can add a button which will trigger the transition when clicked.
Create two classes, View.java
(which is a javafx.application.Application
class, like the aboveit contains the main-launch-start
methods) and Model.java
class (which is an ordinary Java class defining the data). Choose Model to represent a collection of circles of different radii, locations and colours. These must belogical shapes (like abstract geometrical objects), not graphical primitives which JavaFX displays (examples of which we've seen in Ex. 2). Then make the View to create the Modelobject (called model
), read its data which describe the shapes and then generate graphical shapes according to their description in the model
object. Finally, extend the Model to allow the colour to take one of the several values (use private
array field Color[] colours
to choose from) when model
object is created. Then, when the model
is displayed in the View, mouse clicks inside any of the circles result in the colour changesuch that a sequence of successive clicks allow to change the circle colour several times utilising the full gamut.
You will get up to two marks (one for each task), if you submit your work by pushing the local repository using git push
command by Friday, 13 May 2016,to your GitLab repository following the instructions to be providedin the . The code should be placed in the hw7
subdirectory of your locally cloned repository.
HW 7 |
Updated: Sun 12 Jun 2016 17:27:37 AEST • Responsible Officer: JavaScript must be enabled to display this email address. • Page Contact:
+61 2 6125 5111
The Australian National University, Canberra
CRICOS Provider : 00120C ABN : 52 234 063 906