Q.1->
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import java.util.Random;
import javafx.stage.Stage;
import javafx.scene.shape.Circle;
public class CircleE extends Application {
@Override
public void start(Stage stage) {
//Drawing a Circle
Circle circle = new Circle();
//Setting the properties of the
circle
circle.setCenterX(200.0f);
circle.setCenterY(200.0f);
Random R = new Random();
float no = R.nextFloat();
no = no*200;
System.out.println(":-> "+no);
circle.setRadius(no);
//Creating a Group object
Group root = new
Group(circle);
//Creating a scene object
Scene scene = new Scene(root, 600,
300);
//Setting title to the Stage
stage.setTitle("Drawing a
Circle");
//Adding scene to the stage
stage.setScene(scene);
//Displaying the contents of the
stage
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
Q.2->
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
import javafx.scene.text.Text;
import java.util.Random;
public class Name extends Application {
@Override
public void start(Stage stage) {
Text text = new
Text();
text.setText("Ambuj Shukla (Your
Name)");
text.setX(100);
text.setY(100);
Rotate rotate = new Rotate();
Random R = new
Random();
float no = R.nextFloat();
no = no*360;
System.out.println(no);
rotate.setAngle(no);
rotate.setPivotX(150);
rotate.setPivotY(225);
text.getTransforms().addAll(rotate);
Group root = new Group(text);
Scene scene = new Scene(root, 600,
300);
stage.setTitle("Application");
stage.setScene(scene);
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
Q.3->
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
import javafx.scene.paint.Paint;
import java.util.Random;
public class RECTANGLE extends Application {
public Paint randomC() {
Random random = new
Random();
int r =
random.nextInt(255);
int g =
random.nextInt(255);
int b =
random.nextInt(255);
return Color.rgb(r, g,
b);
}
public void start(Stage stage) {
//Drawing Rectangle1
Rectangle rectangle = new
Rectangle(150, 75, 200, 150);
System.out.println(Color.BLUE);
rectangle.setFill(randomC());
rectangle.setStroke(Color.BLACK);
Group root = new
Group(rectangle);
//Creating a scene object
Scene scene = new Scene(root, 600,
300);
stage.setTitle("Rotation
transformation example");
stage.setScene(scene);
//Displaying the contents of the
stage
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
Q.4->
import javafx.animation.Interpolator;
import javafx.animation.PathTransition;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Sphere;
import javafx.stage.Stage;
import javafx.util.Duration;
import javafx.scene.paint.Color;
import javafx.scene.Group;
public class Orbit extends Application {
@Override
public void start(Stage primaryStage) {
Sphere sun = new
Sphere(45);
Sphere p1 = new
Sphere(15);
Sphere p2 = new
Sphere(15);
Sphere p3 = new
Sphere(15);
Ellipse ellipse = new
Ellipse();
ellipse.setCenterX(200);
ellipse.setCenterY(200);
ellipse.setRadiusX(200);
ellipse.setRadiusY(100);
ellipse.setFill(Color.WHITE);
ellipse.setStroke(Color.BLACK);
sun.setTranslateX(200);
sun.setTranslateY(200);
p1.setTranslateX(140);
p1.setTranslateY(100);
p2.setTranslateX(350);
p2.setTranslateY(260);
p3.setTranslateX(180);
p3.setTranslateY(300);
//Creating a Group object
Group root1 = new
Group(ellipse,p1,p2,p3,sun);
//Creating a scene object
Scene scene1 = new Scene(root1, 600,
300);
//Setting title to the Stage
primaryStage.setTitle("Drawing a
Circle");
//Adding scene to the stage
primaryStage.setScene(scene1);
//Displaying the contents of the
stage
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
//Screenshot of Code
//Screenshot of Outputs
/
/If you have any doubt.Please feel free to ask.Thanks
PP.14 PP 3.13 Write a JavaFX application that draws a circle centered at poinit (200, 200) with a random radius in the range 50 to 150. Each time the program is run it will draw a different circle. P...
PP.15 PP 3.13 Write a JavaFX application that draws a circle centered at poinit (200, 200) with a random radius in the range 50 to 150. Each time the program is run it will draw a different circle. PP 3.14 Write a JavaFX application that displays your name rotated at a random angle (0 to 360). Each time the program is run it will draw your name at a different angle. a random color created using the rgb method of...