我有FXML文件,它有tableview,并且包含动态行和列,所以当有更多的行或列时,它应该显示滚动条。
如果我减少/增加高度/宽度,则应相应地滚动。
我的fxml文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.collections.FXCollections ?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ScrollPane?>
<VBox minWidth="-Infinity" minHeight="550.0" stylesheets="@CLsMain.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<HBox minWidth="-Infinity" prefHeight="20.0">
<children>
<ImageView>
<image>
<Image url="@wellsFargoLogo.png" />
</image>
</ImageView>
<Label alignment="CENTER" prefHeight="45.0" prefWidth="810.0" minWidth="-Infinity" style="-fx-background-color: lightGray;" text="FX Continous Linked Settlement" textAlignment="JUSTIFY" wrapText="true">
<font>
<Font name="System Bold" size="16.0" />
</font>
</Label>
</children>
</HBox>
<HBox alignment="CENTER" minWidth="-Infinity" prefHeight="58.0">
<children>
<Label alignment="CENTER" prefHeight="58.0" prefWidth="55.0" text="Config" textAlignment="JUSTIFY" textOverrun="CENTER_ELLIPSIS" wrapText="true">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Label>
<ComboBox prefHeight="26.0" prefWidth="110.0" promptText="Default Config" />
<Label alignment="CENTER" prefHeight="35.0" prefWidth="16.0" textAlignment="JUSTIFY" wrapText="true" />
<Label alignment="CENTER" prefHeight="58.0" prefWidth="80.0" text="Quick Links" textAlignment="JUSTIFY" textOverrun="CENTER_ELLIPSIS" wrapText="true">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Label>
<ComboBox prefHeight="26.0" prefWidth="90.0" promptText="CLS GUI" />
<Label alignment="CENTER" prefHeight="58.0" prefWidth="17.0" textAlignment="JUSTIFY" textOverrun="CENTER_ELLIPSIS" wrapText="true" />
<Button defaultButton="true" mnemonicParsing="false" prefHeight="25.0" prefWidth="79.0" text="Resend" textAlignment="JUSTIFY" styleClass="red-gradient" />
</children>
</HBox>
<TabPane minWidth="-Infinity" tabClosingPolicy="UNAVAILABLE">
<tabs>
<Tab text="Trade Blotter">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="71.0" prefWidth="515.0" />
</content>
</Tab>
<Tab text="Payment">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="58.0" prefWidth="515.0" />
</content>
</Tab>
<Tab text="I/O Swap">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
<Tab text="Exception">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
<Tab text="Non-Repudiation">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
<Tab text="Maintenance">
<content>
<AnchorPane>
<children>
<VBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<HBox alignment="CENTER" minWidth="-Infinity" prefWidth="800.0">
<children>
<Label alignment="CENTER" prefHeight="70.0" prefWidth="100.0" text="Select table" textAlignment="JUSTIFY" textOverrun="CENTER_ELLIPSIS" wrapText="true">
<font><Font name="System Bold" size="12.0" /></font>
</Label>
<ComboBox fx:id="clsTableConfigComboBox" prefHeight="26.0" prefWidth="180.0" promptText="Select Table"></ComboBox>
</children>
</HBox>
<ToolBar>
<items>
<HBox alignment="CENTER_LEFT" prefHeight="31.0" minWidth="-Infinity">
<children>
<!-- <ImageView>
<image>
<Image url="@tabClosedLarge.png" />
</image>
</ImageView> -->
<Button defaultButton="true" mnemonicParsing="false" onAction="#onAddHandler" prefHeight="25.0" prefWidth="59.0" text=" Add " textAlignment="JUSTIFY" styleClass="red-gradient" />
<Label alignment="CENTER" prefHeight="35.0" prefWidth="16.0" textAlignment="JUSTIFY" wrapText="true" />
<!-- <ImageView fitHeight="24.0" fitWidth="24.0">
<image>
<Image url="@tabOpenLarge.png" />
</image>
</ImageView> -->
<Button fx:id="delBtn" defaultButton="true" mnemonicParsing="false" onAction="#onDeleteHandler" prefHeight="25.0" prefWidth="59.0" text="Delete" textAlignment="JUSTIFY" styleClass="red-gradient" />
<Label alignment="CENTER" prefHeight="35.0" prefWidth="16.0" textAlignment="JUSTIFY" wrapText="true" />
<!-- <ImageView fitHeight="24.0" fitWidth="24.0">
<image>
<Image url="@ClearAll.png" />
</image>
</ImageView> -->
<Button defaultButton="true" mnemonicParsing="false" onAction="#onClearHandler" prefHeight="25.0" prefWidth="79.0" text="Clear All" textAlignment="JUSTIFY" styleClass="red-gradient" />
<Label alignment="CENTER" prefHeight="35.0" prefWidth="16.0" textAlignment="JUSTIFY" wrapText="true" />
<!-- <ImageView fitHeight="30.0" fitWidth="27.0">
<image>
<Image url="@excel_logo.gif" />
</image>
</ImageView> -->
<Button defaultButton="true" mnemonicParsing="false" onAction="#onExportHandler" prefHeight="25.0" prefWidth="72.0" text="Download" textAlignment="JUSTIFY" styleClass="red-gradient" />
<Label alignment="CENTER" prefHeight="35.0" prefWidth="16.0" textAlignment="JUSTIFY" wrapText="true" />
<!-- <ImageView fitHeight="30.0" fitWidth="25.0">
<image>
<Image url="@printer-icon.gif" />
</image>
</ImageView> -->
<Button defaultButton="true" mnemonicParsing="false" onAction="#onPrintHandler" prefHeight="25.0" prefWidth="57.0" text="Print" textAlignment="JUSTIFY" styleClass="red-gradient" />
</children>
</HBox>
</items>
</ToolBar>
</children>
<children>
<ScrollPane prefHeight="340.0" prefWidth="850.0">
<TableView fx:id="tblViewer" styleClass="tableview" stylesheets="@ClsMain.css" />
</ScrollPane>
</children>
</VBox>
</children>
</AnchorPane>
</content>
</Tab>
</tabs>
</TabPane>
</children>
</VBox>
你可以帮我解决这个问题吗?
亲切的问候,