Lab Report #9: Mouse Events in JavaFX, Study Guides, Projects, Research of Object Oriented Programming

Object-oriented programming (OOP) refers to a type of computer programming (software design) in which programmers define the data type of a data structure, and also the types of operations (functions) that can be applied to the data structure.

Typology: Study Guides, Projects, Research

2019/2020

Uploaded on 01/11/2020

samia-khan-2
samia-khan-2 🇵🇸

4.8

(4)

11 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
LAB REPORT: #9
SUBJECT Images
SUBMITTED BY: SAMIA
REG. NO: 17JZBCS0022
DEPARTMENT: CS&IT
TITLE: Mouse events
pf3
pf4

Partial preview of the text

Download Lab Report #9: Mouse Events in JavaFX and more Study Guides, Projects, Research Object Oriented Programming in PDF only on Docsity!

LAB REPORT:

SUBJECT Images

SUBMITTED BY: SAMIA

REG. NO: 17JZBCS

DEPARTMENT: CS&IT

TITLE: Mouse events

Exercise 1:

  • In BlueJ, create a new project called Lab9 with a class called Scribbler
  • Add all the necessary scaffolding code to make it a JavaFX applicaFon, imporFng the necessary classes.
  • Create an empty Group and add it to a Scene.
  • Set the scene size to 770 x 500 and the fill color of the scene to black.
  • Declare the Group and Scene variables at the class level because they will later be used in other methods.
  • Run your program to view the empty scene. SOLUTION:

Exercise 2:

  • Download the image sunset.jpg from our Canvas site (under Files > lab files )
  • Move the image to the lab project folder.
  • In the start method, create an Image object with that file.
  • Then create an ImageView object for that image. Declare the ImageView variable at the class level.
  • Set both the x and y posiFon of the image view (its upper leU corner) to 70.
  • Add the image view to the root group. SOLUTION:

Exercise 3:

  • Create a method called addDot to serve as a MouseEvent handler.
  • In the addDot method, create a Circle centered where the mouse was pressed, with a radius of 3 pixels.
  • Add the circle to the (children of the) root group.
  • In the start method, set up the ImageView to call that event handler

Exercise 6:

  • Now add a method called rollOn to handle a MouseEvent whenever the mouse enters (rolls onto) the image.
  • When this happens, change the fill color of the scene to CYAN. SOLUTION: OUTPUT: