
Help, I would also want to know how to draw the stars as well please.
Please find the code below:::
package gui;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class US_Flag extends Application {
@Override
public void start(Stage primaryStage) {
//--Set Properties
Scene scene = new Scene(new
USFlagPane());
primaryStage.setTitle("US
Flag");
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
class USFlagPane extends Pane {
private static final double Pane_W = 718;
private static final double Pane_H = 370;
private static final double BG_W = 310;
private static final double BG_H = 208;
public USFlagPane() {
this.setPrefSize(Pane_W,
Pane_H);
//--Red Stripes
double y = 0;
for (int i = 0; i < 7; i++)
{
Rectangle block
= new Rectangle(0, y, 728, 208.0 / 7.0);
block.setFill(Color.RED);
y += 2 * 208.0 /
7;
this.getChildren().add(block);
}
//--BackGround
Rectangle StarBox = new
Rectangle(0, 0, BG_W, BG_H);
StarBox.setFill(Color.BLUE);
this.getChildren().add(StarBox);
//--Stars
//--Import From Net
//mention path of star here
final String StarPath =
"https://cs.stcc.edu/wp-content/uploads/2017/03/flagstar.png";
Image image = new
Image(StarPath);
//--Controls 6x5
for (int j = 0; j < 5; j++)
{
for (int i = 0;
i < 6; i++) {
ImageView star = new ImageView(image);
star.setX((double) (i * 55 + 8));
star.setY((double) (j * 40 + 12));
star.setFitHeight(20.0);
star.setFitWidth(20.0);
this.getChildren().add(star);
}
}
//--Controls 5x4
for (int j = 0; j < 4; j++)
{
for (int i = 0;
i < 5; i++) {
ImageView star = new ImageView(image);
star.setX((double) (i * 55 + 35));
star.setY((double) (j * 40 + 32));
star.setFitHeight(20.0);
star.setFitWidth(20.0);
this.getChildren().add(star);
}
}
}
public static void main(String[] args) {
Application.launch((String[])args);
}
}
output:
![y+= 2 * 208.0 / 7; US Hac] flag this.getChildren ().add (star);](http://img.homeworklib.com/images/0163ec9f-6b17-47dc-ae5c-d7292c052a81.png?x-oss-process=image/resize,w_560)
in order to draw star , Just download image of star and give the path of it to the as mentioned in the comments
Help, I would also want to know how to draw the stars as well please. JavaFX (50 Pts) r ins Use JavaFX Application to draw the American Flag (without the stars). It has thirteen alternatin,g red and...