Docsity

JavaFX Graphics: Shapes and Color - Lab Report #8, Study Guides, Projects, Research of Mathematics

Partial preview of the text

Download JavaFX Graphics: Shapes and Color - Lab Report #8 and more Study Guides, Projects, Research Mathematics in PDF only on Docsity!

LAB REPORT:

SUBJECT Graphics in

JavaFX

SUBMITTED BY: SAMIA

REG. NO: 17JZBCS

DEPARTMENT: CS&IT

TITLE: Shapes and

color

Exercise 1:

  • In BlueJ, create a new project called Lab
  • Create a class in that project called MyShapes
  • Since this will be a JavaFX applicaDon, add the extends Applica6on clause to the class header.
  • Create the standard JavaFX start method, passing in a Stage object called primaryStage
  • Import the needed classes.
  • Make sure the program compiles, though it won't do anything yet.

SOLUTION:

Exercise 2:

  • Create an empty Group object to serve as the root of the scene.
  • Create a Scene object, specifying the root group and making the scene 500 pixels wide and 300 pixels tall. Give the scene a background color of light blue.
  • Set the Dtle on the primary stage (the main applicaDon window) to "My JavaFX Shapes".
  • Add the scene to the stage.
  • Show the stage.
  • Run the program to see the window. Remember to choose the Run JavaFX Program opDon – you don't run the start method directly.

width of 20, and a pink fill.

SOLUTION:

Exercise 6:

  • Create a general snowman shape using two ellipses and a circle as shown below.
  • Use a fill of white for each, and don't set the stroke.

SOLUTION:

Exercise 7:

  • "Sign" your artwork by puZng your name (using a Text object) in the bo[om right corner of the scene.

SOLUTION:

OUTPUT: