/home/caleb/ASDV-Java/Semester 2/Assignments/JavaFX_CalebFontenot/src/javafx_calebfontenot/Checkerboard.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package javafx_calebfontenot;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
@author
public class Checkerboard extends Application {
@Override
public void start(Stage primaryStage) throws Exception
{
Pane pane = new Pane();
Scene scene = new Scene(pane, 800, 800);
primaryStage.setScene(scene);
primaryStage.show();
Rectangle[][] r = new Rectangle[8][8];
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
r[i][j] = new Rectangle();
}
}
int j = 0;
for (int i = 0; i < 8; ++i) {
for (j = 0; j < 8; ++j) {
r[i][j].setWidth(80);
r[i][j].setHeight(80);
if (j > 0) {
r[i][j].setX(r[i][j - 1].getX() + 75);
}
if ((i + j) % 2 == 0) {
r[i][j].setFill(Color.RED);
} else {
r[i][j].setFill(Color.BLACK);
}
r[i][j].setY((i + 1) * 75);
pane.getChildren().add(r[i][j]);
}
}
}
public static void main(String[] args)
{
launch(args);
}
}