Local variable defined in an enclosing scope
Go to solution
Solved by TheBean,
Thats actuallly a really good implementation. I didnt know evenhandlers had that .clickedButton function.
But, I found a better implementation on stackoverflow.
for (int i = 0; i < gridSize; i++) { for (int j = 0; j < gridSize; j++) { String text = i + "" + j; Button button = buttonGrid[i][j] ; button.setOnAction(e -> { button.setText(text); }); gridpane.getChildren().add(buttonGrid[i][j]); } }
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now