Question
please help me modify my code so that it prints out like below import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.GridPane; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle;
please help me modify my code so that it prints out like below
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javax.swing.JOptionPane;
public class MaddeningMatrices extends Application {
public void start(Stage primaryStage) {
GridPane pane = new GridPane();
// StackPane stack = new StackPane();
String input = JOptionPane.showInputDialog("Enter number: ");
int number = Integer.parseInt(input);
for (int row = 0; row
for (int col = 0; col
StackPane stack = new StackPane();
double rotation = Math.random()*(360-0)+0;
double s = Math.random() * (70 - 25) + 25;
double transparency = Math.random()*(1.0-0.50)+0.50;
Rectangle rec = new Rectangle();
rec.setWidth(s);
rec.setHeight(s);
rec.setRotate(rotation);
rec.setFill(Color.color(Math.random(),Math.random(),Math.random(), transparency));
GridPane.setRowIndex(rec, row);
GridPane.setColumnIndex(rec, col);
// for(int i = 1;i
// Text text = new Text(Integer.toString(i));
// text.setFill(Color.color(Math.random(), Math.random(), Math.random(),1.0));
// text.setRotate(Math.random()*(360-0)+0);
//
// stack.getChildren().add(rec);
pane.getChildren().add(rec);
}
}
Scene scene = new Scene(pane);
primaryStage.setTitle("Show Maddening Matrices");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main (String[] args) {
Application.launch(args);
}
}
i cant printout the numbers ... my teacher suggests that we create text object and add it to stackpane.. idk how to do tht..
here is his advice:
You will want a new stack pane for each grid block and you want to add the square and the text to the stack pane, THEN add the stack pane to a specific location ont he gridpane, THEN add the gridpane to your scene and so on.
good answer wouldrated high
4 6 8 ? 18 2 0 ? 39 45 47 50 5 8S 64 4 6 8 ? 18 2 0 ? 39 45 47 50 5 8S 64Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started