Question: i'm having a problem on javafx i need to store the shapes in array place them randomly using java.util.ramdom but I don't know how here

i'm having a problem on javafx

i need to store the shapes in array place them randomly using java.util.ramdom but I don't know how

here is the code

package javafxapplication1;
import java.util.Random;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Line;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class ShowShapes extends Application {

@Override
public void start(Stage primaryStage) {

GridPane pane = new GridPane();
Random n = new Random();
Text text = new Text("WELCOME JAVAFX ");
text.setStroke(Color.RED);

Line line = new Line(0, 0, 100, 100);
text.setStroke(Color.YELLOWGREEN);

Circle c = new Circle(50);
c.setStroke(Color.BLACK);
c.setFill(Color.RED);
  

Rectangle r = new Rectangle(100, 100);
 
r.setStroke(Color.BLACK);
r.setFill(Color.RED);

Circle c2 = new Circle(50);
c2.setStroke(Color.GREEN);
c2.setFill(Color.BLUE);

Ellipse e = new Ellipse(50, 25);

e.setStroke(Color.YELLOW);
e.setFill(Color.ORANGE);

pane.add(text, 0, 0);

pane.add(line, 1, 0);

pane.add(c, 2, 0);

pane.add(r, 0, 1);

pane.add(c2, 1, 1);

pane.add(e, 2, 1);

Scene scene = new Scene(pane, 305, 200);
primaryStage.setTitle("Show Shapes");
primaryStage.setScene(scene);
primaryStage.show();

}

}

Step by Step Solution

3.42 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Code as per the instruction provided please let me know if you need any more help is required Explan... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

608c00a37e473_208171.pdf

180 KBs PDF File

Word file Icon

608c00a37e473_208171.docx

120 KBs Word File

Students Have Also Explored These Related Computer Network Questions!