i'am working a project that involves array of checkboxes. but i encounter a problem when i'm adding all the checkboxes in VBox. here is my screenshot below
Other checkboxes cannot be viewed.
here is my code for checkboxes
public void initializeSenatorLists() {
CheckBox []chckSenators = new CheckBox[senators.length];
for(int s=0; s < senators.length; s++) {
chckSenators[s] = new CheckBox(senators[s]);
chckSenators[s].setStyle("-fx-font-size:15px;");
chckSenators[s].setTextFill(Color.WHITE);
senVbox.getChildren().add(chckSenators[s]);
}
for(CheckBox cbSen:chckSenators) {
cbSen.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
if(cbSen.isSelected()) {
senatorLimitVote++;
votedSenators.add(cbSen.getText());
}else {
votedSenators.remove(cbSen.getText());
senatorLimitVote--;
}
}
});
}
}
What i want to do to my checkboxes is this
I hope you can help me.
The ScrollPane allows the application to set the current, minimum, and maximum values for positioning the contents in the horizontal and vertical directions. These values are mapped proportionally onto the layoutBounds of the contained node.
The ListView class represents a scrollable list of items.
To add some buttons to the VBox use the getChildren(). add() function. Finally, create a scene and add the vbox to the scene and add the scene to the stage and call show() function to display the final results.
Try putting VBox inside a scrollPane. With this approach, you don't have to worry about setting the prefHeight and prefWidth attributes. You can use 'USE_COMPUTED_SIZE' for the VBox.
Example: VBox is added inside a ScrollPane, and various elements like HBox, Labels, and rectangles are added dynamically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With