0

我想在我的应用程序中添加长文本。当我单击 POKAŻ 按钮时,它会向我显示来自名为 Dream 的类的梦想字段(字符串)。在这里我有一个问题。我的梦的内容很长,没有完全展现出来。当我将它包装在 ScrollPane 中时,它只显示一行文本。

这是我的应用程序的打印屏幕。

在此处输入图像描述

我可能会在单击 POKAŻ 按钮后添加它会更改 .fxml 文件

        public void showMeMyDream(ActionEvent e) throws IOException
    {
 showSelectedDream();
contentID.getChildren().clear();  contentID.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/showDreamFXML.fxml")));

    }

这是showDreamFXML.fxml的代码

<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.VBox?>

<AnchorPane maxHeight="1.7976931348623157E308" nodeOrientation="LEFT_TO_RIGHT" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller.ShowDreamController">
   <children>
      <VBox maxHeight="1.7976931348623157E308" nodeOrientation="LEFT_TO_RIGHT" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
         <children>
            <GridPane>
              <columnConstraints>
                <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
              </columnConstraints>
              <rowConstraints>
                <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                  <RowConstraints minHeight="10.0" vgrow="ALWAYS" />
              </rowConstraints>
               <children>
                  <Label text="Label" GridPane.rowIndex="5" />
                  <Label fx:id="showDreamContent" text="Label" wrapText="true" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="5" GridPane.vgrow="ALWAYS" />
                  <Label text="Label" GridPane.rowIndex="4" />
                  <Label fx:id="showDreamLength" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="4" />
                  <Label text="Label" GridPane.rowIndex="3" />
                  <Label fx:id="showDreamType" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="3" />
                  <Label fx:id="showDreamMem" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="2" />
                  <Label fx:id="showDreamDate" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="1" />
                  <Label text="Label" />
                  <Label text="Label" GridPane.rowIndex="1" />
                  <Label text="Label" GridPane.rowIndex="2" />
                  <Label fx:id="showDreamTitle" text="Label" GridPane.columnIndex="1" />
               </children>
            </GridPane>
            <HBox>
               <children>
                  <Button mnemonicParsing="false" text="Button" />
               </children>
            </HBox>
         </children>
      </VBox>
   </children>
</AnchorPane>
4

0 回答 0