JAVA: Im new to GUI and have created this grid, but cant figure out how to add clickable buttons to.
JAVA: Im new to GUI and have created this grid, but cant figure out how to add clickable buttons to all of the circles on the top row. Could someone show me how to do this? I dont need action listeners. Just clickable buttons for now. Thanks! import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.scene.Scene;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.layout.GridPane;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Shape;
import javafx.stage.Stage; public class Grid extends Application { private static final int TILE_SIZE = 80;
private static final int COLUMNS = 6;
private static int ROWS = 7; public static void main(String[] args) {
//Stage stage = new Stage();
//start(stage);
launch(args); } @Override
public void start(Stage primaryStage) { Shape shape = new Rectangle((COLUMNS + 2) * TILE_SIZE, (ROWS) * TILE_SIZE);
for (int i = 0; i < rows;="" i++)="">
for (int i2 = 0; i2 < columns;="" i2++)="">
Circle circle = new Circle(TILE_SIZE / 2);
circle.setCenterX(TILE_SIZE / 2);
circle.setCenterY(TILE_SIZE / 2);
circle.setTranslateX(i * (TILE_SIZE + 5) + TILE_SIZE / 4);
circle.setTranslateY(i2 * (TILE_SIZE + 5) + TILE_SIZE / 4);
shape = Shape.subtract(shape, circle);
}
}
GridPane pane = new GridPane();
pane.setAlignment(Pos.CENTER);
pane.setPadding(new Insets(11.5, 12.5, 13.5, 14.5)); // pixel buffer layout
pane.setHgap(5.5); // pixel per blocks
pane.setVgap(5.5); pane.getChildren().addAll(shape); Scene scene = new Scene(pane);
primaryStage.setTitle(“GridPane”); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
} } May 13 2022 07:28 PM
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more