Question: You will use the FXGraphicsTemplate for this. Setup Use the FXGraphicsTemplate for this assignment. Change the class name to something meaningful and change the window
You will use the FXGraphicsTemplate for this.
Setup
Use the FXGraphicsTemplate for this assignment. Change the class name to something meaningful and
change the window title, and size of the stage to whatever you want.
When your program runs, the first thing you should do is create a star field by displaying a whole bunch
of randomlyplaced stars ie small circles or squares on a black or very dark blue screen. You can use
the formula Math.randomMAX to generate a random value between and MAX. Its up to you
how many stars you display in this way but it should be enough to look like the actual night sky To
make it look more realistic, you could also vary the size or brightness of the stars.
Input
Then have a dialog with the user dont show the JavaFX stage until after this dialog is over This dialog
should ask the user for the following:
Number of stars in the constellation
Enter the X and Y values for each star
position
Title of their constellation
Make sure the user cannot enter x or y values
that would appear off screen.
As the user is entering legal values, you
should be drawing stars on the screen and
connecting each star to the last one by drawing
a line.
You can decide exactly what all this will look
like, but your stars should be different enough
that they will stand out from the other stars
that are already on the screen.
When the user is finished, connect the last star back to the first one. Draw the constellation title somewhere on
the screen using a nice font and color, and
display your own programming credits on
the screen as well ieapp created by
Josephine Smith or something like that
EX of FXGraphicsTemplate.java:
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.stage.Stage;
import static javafx.application.Application.launch;
Use this template to create drawings in FX
Change the name of the class and
put your own name as author below. Change the size of the canvas and the
window title where marked and add your drawing code where marked.
public class FXGraphicsTemplate extends Application
Start method
use this instead of main
@param stage The FX stage to draw on
@throws Exception
@Override
public void start
Stage stage
throws Exception
Group root
new Group
;
Scene scene
new Scene
root
;
Canvas canvas
new Canvas
;
Set canvas Size in Pixels
stage.setTitle
FXGraphicsTemplate
;
Set window title
root.getChildren
add
canvas
;
stage.setScene
scene
;
GraphicsContext gc
canvasgetGraphicsContext
D
;
YOUR CODE STARTS HERE
YOUR CODE STOPS HERE
stage.show
;
The actual main method that launches the app.
@param args unused
public static void main
String
args
launch
args
;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
