JavaFX ScrollPane не распознает мой негабаритный VBox

Я довольно новичок в JavaFX, и у меня возникла следующая проблема: у меня есть программа, которая рассчитывает все возможные совпадения между командами в каждом против каждого сценария. That's why there are a lot of matches in total. And there comes my problem: I've got a ScrollPane containing an AnchorPane that holds a VBox (VBOX_matches in the code). This VBox contains HBoxes based on the amount of all possible matches. My thought was: as it extends the size of the program window the other matches have to be seen. Let's add a scrollpane as many people suggested in a forum. But this scrollpane always stays at 100% and is not scrollable. Что я делаю неправильно? Это вообще возможно?

https://ibb.co/c3WVEc //Link to the screenshot. I can't upload pictures somehow

  this.matches = gameManagement.getMatches();
  for (int i = 0; i < matches.size(); i++) {
        String team1 = ((Team)((Pair)matches.get(i)).getKey()).getTeamname();
        String team2 = ((Team)((Pair)matches.get(i)).getValue()).getTeamname();
        HBox box = new HBox();
        box.setSpacing(20);
        Label first = new Label(team1);
        first.setMinSize(LABEL_TEAM_WIDTH,LABEL_TEAM_HEIGHT);
        first.setMaxSize(LABEL_TEAM_WIDTH,LABEL_TEAM_HEIGHT);
        first.setPadding(new Insets(0,0,0,PADDING));
        first.setTextAlignment(TextAlignment.CENTER);
        first.setFont(Font.font("Bold",TEAM_FONT_SIZE));

        box.getChildren().add(first);

        VBOX_matches.getChildren().add(box);

Файл FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.media.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0"
            prefWidth="1100.0" style="-fx-background-color: gray;" xmlns="http://javafx.com/javafx/8"
            xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.gui.GameController">
    <children>
        <SplitPane dividerPositions="0.6539162112932605" layoutX="377.0" layoutY="253.0" prefHeight="700.0"
                   prefWidth="1100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
                   AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
            <items>
                <ScrollPane fx:id="scroll" fitToHeight="true" fitToWidth="true" maxHeight="1.7976931348623157E308"
                            maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" pannable="true"
                            prefHeight="698.0" prefWidth="682.0" vbarPolicy="ALWAYS"
                            SplitPane.resizableWithParent="false">
                    <content>
                        <AnchorPane fx:id="scroll_pane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
                                    minWidth="-Infinity" prefHeight="698.0" prefWidth="714.0">
                            <children>
                                <VBox fx:id="VBOX_matches" layoutX="-6.0" maxHeight="-Infinity" maxWidth="-Infinity"
                                      minHeight="-Infinity" minWidth="-Infinity" prefHeight="698.0" prefWidth="714.0"
                                      AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
                                      AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
                            </children>
                        </AnchorPane>
                    </content>
                </ScrollPane>

0 ответов

Другие вопросы по тегам