I currently have a program where you can press one "stack button" and create 9 stacks (which are just buttons). However, I want it to where each button has it's own identity, so if I click on a specific one, and it will take me to a specific window for each.
Here is my code:
private void createButtonActivate(){
System.out.println("A stack has been created");
stackCount++;
newStackButton = new Button((Integer.toString(stackCount)));
newStackButton.setOnAction(actionEvent -> {
methods.openNoteCard();
});
root.getChildren().add(newStackButton);
}
Here is what is called to create the Buttons:
private void createStack(){
stackCreated = true;
if (stackCount < 3 ) {
createButtonActivate();
buttonXPos = buttonXPos + 150;
}
else if (stackCount >= 3 && stackCount < 6){
if (stackCount == 3){
buttonXPos = 50;
buttonYPos = buttonYPos + 150;
}
createButtonActivate();
buttonXPos = buttonXPos + 150;
// buttonXPos =
}
else if (stackCount >= 6 && stackCount < 9){
if (stackCount == 6){
buttonXPos = 50;
buttonYPos = buttonYPos + 150;
}
createButtonActivate();
buttonXPos = buttonXPos + 150;
}
}
I hope I didn't provide too much code and I actually explained my problem thoroughly haha anyway, thank you for any help!
StackPaneis the best layout option here? You may be able to save a lot of work and trouble by using a layout that arranges the buttons for you (instead of trying to lay them out at precise coordinates yourself).FlowPaneif you want to add multiple nodes in a row and have them flow to the next line. Or aGridPaneif you want them evenly spaced in precise row/column locations. There are a lot of options. Google for JavaFX layouts and take a look :)