0

So i want to create a list of button for each element on my array. If i have 10 objects on the array, i want to create 10 buttons right away. Thank you

1
  • 1
    Please show us some code. What have tried so far? What does your array contain? Commented May 22, 2017 at 2:44

1 Answer 1

1

Create buttons where? You need a container to add them to (IIRC something that extends Parent).

String[] sa = new String[10];
for (String s : sa) {
  Button b = new Button(s);
  vBox.getChildren().add(b);
}

If you use SceneBuilder and FXML to design your views (leaving out anything dynamic like this), you can assign containers like a VBox an ID, which will automatically add a reference with an @FXML annotation when you generate a controller class. That will give you a reference to a container to add the buttons to.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.