Anchorpane内部HBox中的Tabpane无法在最大化窗口时调整大小

时间:2019-09-21 14:25:29

标签: fxml scenebuilder

我是fxml和Scene Builder的新手,正在致力于设计一个GUI以发送Post请求。

我在锚定窗格内的HBox中放置了两个选项卡窗格。左侧的标签窗格包含两个用于请求的标题和正文,右侧的标签窗格包含响应的标题和正文。

在最大化窗口时,我看到两个选项卡窗格都已折叠。我试图为两个HBox设置锚窗格的布局,但这不起作用。

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

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="429.0" prefWidth="694.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <VBox layoutX="39.0" layoutY="14.0" prefHeight="30.0" prefWidth="584.0" AnchorPane.leftAnchor="39.0" AnchorPane.rightAnchor="71.0">
         <children>
            <TextField prefHeight="25.0" prefWidth="641.0" />
         </children>
      </VBox>
      <Label layoutX="14.0" layoutY="20.0" text="URL" />
      <Button layoutX="628.0" layoutY="11.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="59.0" text="POST" AnchorPane.rightAnchor="7.0" />


      <HBox layoutX="14.0" layoutY="44.0" prefHeight="379.0" prefWidth="349.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="350.0" AnchorPane.topAnchor="44.0">
         <children>
            <TabPane prefHeight="383.0" prefWidth="339.0" tabClosingPolicy="UNAVAILABLE" HBox.hgrow="ALWAYS">
              <tabs>
                <Tab text="Head">
                  <content>
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="339.0" prefWidth="349.0" />
                  </content>
                </Tab>
                <Tab text="Body">
                  <content>
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
                  </content>
                </Tab>
              </tabs>
            </TabPane>
         </children>
      </HBox>
      <HBox layoutX="371.0" layoutY="44.0" prefHeight="379.0" prefWidth="311.0" AnchorPane.leftAnchor="360.0" AnchorPane.rightAnchor="0.0">
         <children>
            <TabPane prefHeight="379.0" prefWidth="314.0" tabClosingPolicy="UNAVAILABLE">
              <tabs>
                <Tab text="Head">
                  <content>
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="350.0" prefWidth="306.0" />
                  </content>
                </Tab>
                <Tab text="Body">
                  <content>
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
                  </content>
                </Tab>
              </tabs>
            </TabPane>
         </children>
      </HBox>
      <Separator layoutX="344.0" layoutY="44.0" orientation="VERTICAL" prefHeight="379.0" prefWidth="13.0" />
   </children>
</AnchorPane>

我试图用VBox和HBox包裹所有组件,但这也不起作用。

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

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>


<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="460.0" prefWidth="630.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="learnfxml.MSDETabContentController">
   <children>
      <VBox prefHeight="70.0" prefWidth="560.0" spacing="5.0" AnchorPane.bottomAnchor="481.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="62.0" AnchorPane.topAnchor="0.0">
         <children>
            <TextField fx:id="a3sUrlTxtFld" prefHeight="25.0" prefWidth="469.0" promptText="A3S URL">
               <VBox.margin>
                  <Insets />
               </VBox.margin>
            </TextField>
            <TextField fx:id="msdeUrlTxtFld" prefHeight="25.0" prefWidth="469.0" promptText="MSDE URL" />
         </children>
         <padding>
            <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
         </padding>
      </VBox>
      <VBox prefHeight="64.0" prefWidth="63.0" spacing="5.0" AnchorPane.rightAnchor="0.0">
         <children>
            <Button fx:id="sendBtn" mnemonicParsing="false" prefHeight="23.0" prefWidth="59.0" text="Send" />
            <Button fx:id="saveBtn" mnemonicParsing="false" prefHeight="22.0" prefWidth="59.0" text="Save" />
         </children>
         <padding>
            <Insets top="5.0" />
         </padding>
      </VBox>
      <VBox layoutY="52.0" prefHeight="491.0" prefWidth="309.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="321.0" AnchorPane.topAnchor="65.0">
         <children>
            <HBox prefHeight="479.0" prefWidth="322.0" VBox.vgrow="ALWAYS">
               <children>
                  <TabPane prefHeight="483.0" prefWidth="324.0" tabClosingPolicy="UNAVAILABLE">
                    <tabs>
                      <Tab text="Untitled Tab 1">
                        <content>
                          <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="464.0" prefWidth="309.0" />
                        </content>
                      </Tab>
                      <Tab text="Untitled Tab 2">
                        <content>
                          <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
                        </content>
                      </Tab>
                    </tabs>
                  </TabPane>
               </children>
            </HBox>
         </children>
      </VBox>
      <VBox layoutX="321.0" layoutY="64.0" prefHeight="475.0" prefWidth="309.0" AnchorPane.bottomAnchor="8.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="65.0">
         <children>
            <HBox prefHeight="479.0" prefWidth="322.0" VBox.vgrow="ALWAYS">
               <children>
                  <TabPane prefHeight="483.0" prefWidth="324.0" tabClosingPolicy="UNAVAILABLE">
                     <tabs>
                        <Tab text="Untitled Tab 1">
                           <content>
                              <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="431.0" prefWidth="309.0" />
                           </content>
                        </Tab>
                        <Tab text="Untitled Tab 2">
                           <content>
                              <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
                           </content>
                        </Tab>
                     </tabs>
                  </TabPane>
               </children>
            </HBox>
         </children>
      </VBox>
   </children>
</AnchorPane>

我尝试使用包裹在堆栈窗格中的网格窗格,这也不起作用。

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

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>


<AnchorPane fx:id="anchorPaneMSDETab" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="745.0" prefWidth="1139.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="learnfxml.MSDETabContentController">
   <children>
      <VBox prefHeight="64.0" prefWidth="787.0" spacing="5.0" AnchorPane.bottomAnchor="585.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="62.0" AnchorPane.topAnchor="0.0">
         <children>
            <TextField fx:id="a3sUrlTxtFld" prefHeight="25.0" prefWidth="469.0" promptText="A3S URL">
               <VBox.margin>
                  <Insets />
               </VBox.margin>
            </TextField>
            <TextField fx:id="msdeUrlTxtFld" prefHeight="25.0" prefWidth="469.0" promptText="MSDE URL" />
         </children>
         <padding>
            <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
         </padding>
      </VBox>
      <VBox prefHeight="64.0" prefWidth="63.0" spacing="5.0" AnchorPane.rightAnchor="0.0">
         <children>
            <Button fx:id="sendBtn" mnemonicParsing="false" prefHeight="23.0" prefWidth="59.0" text="Send" />
            <Button fx:id="saveBtn" mnemonicParsing="false" prefHeight="22.0" prefWidth="59.0" text="Save" />
         </children>
         <padding>
            <Insets top="5.0" />
         </padding>
      </VBox>
      <VBox layoutY="65.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="65.0">
         <children>
            <StackPane VBox.vgrow="ALWAYS">
               <children>
                  <GridPane>
                     <columnConstraints>
                        <ColumnConstraints hgrow="SOMETIMES" maxWidth="600.0" minWidth="10.0" prefWidth="440.0" />
                        <ColumnConstraints hgrow="SOMETIMES" maxWidth="509.0" minWidth="10.0" prefWidth="436.0" />
                     </columnConstraints>
                     <rowConstraints>
                        <RowConstraints vgrow="ALWAYS" />
                     </rowConstraints>
                     <children>
                        <TabPane fx:id="requestTabPane" prefHeight="483.0" prefWidth="324.0" tabClosingPolicy="UNAVAILABLE" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
                          <tabs>
                            <Tab text="Untitled Tab 1">
                              <content>
                                <AnchorPane />
                              </content>
                            </Tab>
                            <Tab text="Untitled Tab 2">
                              <content>
                                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="450.0" prefWidth="400.0" />
                              </content>
                            </Tab>
                          </tabs>
                        </TabPane>
                        <TabPane prefHeight="680.0" prefWidth="525.0" tabClosingPolicy="UNAVAILABLE" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
                           <tabs>
                              <Tab text="Untitled Tab 1">
                                 <content>
                                    <AnchorPane />
                                 </content>
                              </Tab>
                              <Tab text="Untitled Tab 2">
                                 <content>
                                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
                                 </content>
                              </Tab>
                           </tabs>
                        </TabPane>
                     </children>
                  </GridPane>
               </children>
            </StackPane>
         </children>
      </VBox>
   </children>
</AnchorPane>

0 个答案:

没有答案