NB! The practical session exercises are always provided enough and to spare with an eye to fast / experienced students have exercises to solve. To this end, do not get upset if you do not get on all the task in class. Take your time and complete the tasks at home!
Task 1. Position of the mouse
Write a program which shows the position (coordinates x and y) of the mouse when the mouse button is pressed. The information must be placed at the same place where the mouse button has been pressed. Once the mouse button is released, the information must disappear.
An example of the program output:
Task 2. Flag
Upgrade the flag program of the 8th home assignment as follows. If the window is resized using the mouse, the flag has to be resized accordingly.
Hints:
There is no particular event for resizing the window; therefore, apply the change listener to the stage properties (widthProperty and heightProperty). Create a method for the canvas drawing and call it when the size of the window is changed. Bind the size of the canvas with the size of the window using the method bind() (e.g. myCanvas.widthProperty().bind(myStage.widthProperty());
). More info about binding is here.
Task 3. Calculator
Write a program which creates a calculator window. Add event handlers. All the buttons must function.
An example of the program output: