Как сделать так, чтобы представление таблицы в vbox росло на границе с помощью Javafx Scene Builder? - PullRequest
0 голосов
/ 03 июня 2019

На первом скриншоте видно, что просмотр таблицы расположен правильно. На втором снимке экрана, когда приложение изменено до максимального размера, табличное представление не увеличивается, чтобы заполнить промежуток от нижней части таблицы до нижней части панели. Как мне заполнить этот пробел? Я установил максимальную высоту на максимум для всех элементов уже. Не уверен, что еще делать.

enter image description here

enter image description here

enter image description here

код customer.fxml

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

<?import java.lang.String?>
<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gci.controllers.CustomerController">
   <children>
      <AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" styleClass="back-white" VBox.vgrow="ALWAYS">
         <children>
            <VBox layoutX="32.0" layoutY="89.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" style="-fx-background-color: orange; -fx-border-color: #003366;" AnchorPane.leftAnchor="25.0" AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="75.0">
               <children>
                  <HBox spacing="10.0" VBox.vgrow="NEVER">
                     <children>
                        <Button fx:id="addButton" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#handleAddButton" prefHeight="30.0" prefWidth="85.0" text="Add">
                           <graphic>
                              <ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
                                 <image>
                                    <Image url="@../assets/images/add.png" />
                                 </image>
                              </ImageView>
                           </graphic>
                           <styleClass>
                              <String fx:value="hover-hand" />
                              <String fx:value="hover-light-blue" />
                           </styleClass>
                           <effect>
                              <DropShadow height="25.0" offsetX="4.0" offsetY="4.0" radius="12.0" width="25.0" />
                           </effect>
                        </Button>
                        <Button fx:id="modifyButton" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#handleModifyButton" prefHeight="30.0" prefWidth="85.0" text="Modify">
                           <graphic>
                              <ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
                                 <image>
                                    <Image url="@../assets/images/edit.png" />
                                 </image>
                              </ImageView>
                           </graphic>
                           <styleClass>
                              <String fx:value="hover-hand" />
                              <String fx:value="hover-light-blue" />
                           </styleClass>
                           <effect>
                              <DropShadow height="25.0" offsetX="4.0" offsetY="4.0" radius="12.0" width="25.0" />
                           </effect>
                        </Button>
                        <Button fx:id="deleteButton" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#handleDeleteButton" prefHeight="30.0" prefWidth="85.0" text="Delete">
                           <graphic>
                              <ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
                                 <image>
                                    <Image url="@../assets/images/trash.png" />
                                 </image>
                              </ImageView>
                           </graphic>
                           <styleClass>
                              <String fx:value="hover-hand" />
                              <String fx:value="hover-light-blue" />
                           </styleClass>
                           <effect>
                              <DropShadow height="25.0" offsetX="4.0" offsetY="4.0" radius="12.0" width="25.0" />
                           </effect>
                        </Button>
                        <Region prefHeight="10.0" prefWidth="50.0" HBox.hgrow="ALWAYS" />
                        <Button fx:id="searchButton" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#handleSearchButton" prefHeight="30.0" prefWidth="85.0" text="Search">
                           <graphic>
                              <ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
                                 <image>
                                    <Image url="@../assets/images/search.png" />
                                 </image>
                              </ImageView>
                           </graphic>
                           <styleClass>
                              <String fx:value="hover-hand" />
                              <String fx:value="hover-light-blue" />
                           </styleClass>
                           <effect>
                              <DropShadow height="25.0" offsetX="4.0" offsetY="4.0" radius="12.0" width="25.0" />
                           </effect>
                           <HBox.margin>
                              <Insets />
                           </HBox.margin>
                        </Button>
                        <TextField fx:id="searchTextField" promptText="Search by customer name" style="-fx-prompt-text-fill: #88B3D9;" styleClass="back-light-blue" HBox.hgrow="ALWAYS">
                           <effect>
                              <DropShadow color="#3c3737" height="25.0" offsetX="4.0" offsetY="4.0" radius="12.0" width="25.0" />
                           </effect>
                        </TextField>
                     </children>
                     <VBox.margin>
                        <Insets bottom="10.0" />
                     </VBox.margin>
                  </HBox>
                  <TableView fx:id="mainTableView" focusTraversable="false" maxHeight="1.7976931348623157E308" prefHeight="528.0" prefWidth="874.0">
                     <columns>
                        <TableColumn fx:id="nameColumn" prefWidth="75.0" text="Name" />
                        <TableColumn fx:id="phoneColumn" prefWidth="75.0" text="Phone" />
                        <TableColumn fx:id="addressColumn" prefWidth="75.0" text="Address" />
                        <TableColumn fx:id="cityColumn" prefWidth="75.0" text="City" />
                        <TableColumn fx:id="postalColumn" prefWidth="75.0" text="Postal Code" />
                        <TableColumn fx:id="countryColumn" prefWidth="75.0" text="Country" />
                     </columns>
                     <columnResizePolicy>
                        <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
                     </columnResizePolicy>
                     <effect>
                        <DropShadow blurType="GAUSSIAN" height="25.0" offsetX="4.0" offsetY="4.0" radius="12.0" width="25.0" />
                     </effect>
                  </TableView>
               </children>
               <padding>
                  <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
               </padding>
            </VBox>
            <Label id="title" fx:id="titleLabel" layoutX="40.0" layoutY="14.0" text="Customers" textFill="#002e51">
               <font>
                  <Font name="PT Serif Caption" size="36.0" />
               </font>
            </Label>
         </children>
      </AnchorPane>
   </children>
   <stylesheets>
      <URL value="@../assets/stylesheets/app.css" />
      <URL value="@../assets/stylesheets/customer.css" />
   </stylesheets>
</VBox>

код app.fxml (панель мониторинга пограничной панели, которая применяет customer.fxml к центральной панели)

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

<?import java.lang.String?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

<BorderPane fx:id="border_pane" prefHeight="700.0" prefWidth="1200.0" styleClass="back-white" stylesheets="@../assets/stylesheets/app.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gci.controllers.AppController">
   <center>
      <VBox alignment="CENTER" styleClass="back-white" BorderPane.alignment="CENTER">
         <children>
            <ImageView fitHeight="400.0" fitWidth="400.0" pickOnBounds="true" preserveRatio="true">
               <image>
                  <Image url="@../assets/images/logo%20200.png" />
               </image>
            </ImageView>
         </children></VBox>
   </center>
   <left>
      <HBox BorderPane.alignment="CENTER">
         <children>
            <VBox styleClass="back-dark-blue">
               <children>
                  <HBox>
                     <children>
                        <ImageView fitHeight="200.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
                           <image>
                              <Image url="@../assets/images/logo%20200.png" />
                           </image>
                        </ImageView>
                     </children>
                     <padding>
                        <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
                     </padding>
                     <VBox.margin>
                        <Insets bottom="5.0" />
                     </VBox.margin>
                  </HBox>
                  <VBox alignment="CENTER_LEFT" layoutX="10.0" layoutY="210.0">
                     <children>
                        <Button alignment="BASELINE_LEFT" graphicTextGap="10.0" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Appointments" VBox.vgrow="ALWAYS">
                           <styleClass>
                              <String fx:value="back-transparent" />
                              <String fx:value="fill-white" />
                              <String fx:value="fn-18" />
                              <String fx:value="hover-hand" />
                              <String fx:value="hover-light-blue" />
                           </styleClass>
                           <graphic>
                              <ImageView fitHeight="30.0" fitWidth="30.0" pickOnBounds="true" preserveRatio="true">
                                 <image>
                                    <Image url="@../assets/images/appt.png" />
                                 </image>
                              </ImageView>
                           </graphic>
                        </Button>
                     </children>
                     <VBox.margin>
                        <Insets bottom="5.0" />
                     </VBox.margin>
                     <padding>
                        <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
                     </padding>
                     <styleClass>
                        <String fx:value="hover-hand" />
                        <String fx:value="hover-light-blue" />
                     </styleClass>
                  </VBox>
                  <VBox alignment="CENTER_LEFT" layoutX="10.0" layoutY="675.0">
                     <children>
                        <Button alignment="BASELINE_LEFT" graphicTextGap="10.0" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Calendar" VBox.vgrow="ALWAYS">
                           <styleClass>
                              <String fx:value="back-transparent" />
                              <String fx:value="fill-white" />
                              <String fx:value="fn-18" />
                              <String fx:value="hover-hand" />
                              <String fx:value="hover-light-blue" />
                           </styleClass>
                           <graphic>
                              <ImageView fitHeight="30.0" fitWidth="30.0" pickOnBounds="true" preserveRatio="true">
                                 <image>
                                    <Image url="@../assets/images/calendar.jpg" />
                                 </image>
                              </ImageView>
                           </graphic>
                        </Button>
                     </children>
                     <VBox.margin>
                        <Insets bottom="5.0" />
                     </VBox.margin>
                     <padding>
                        <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
                     </padding>
                     <styleClass>
                        <String fx:value="hover-hand" />
                        <String fx:value="hover-light-blue" />
                     </styleClass>
                  </VBox>
                  <VBox alignment="CENTER">
                     <children>
                        <Button alignment="BASELINE_LEFT" graphicTextGap="10.0" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onMouseClicked="#show_customers" text="Customers" VBox.vgrow="ALWAYS">
                           <styleClass>
                              <String fx:value="back-transparent" />
                              <String fx:value="fill-white" />
                              <String fx:value="fn-18" />
                              <String fx:value="hover-hand" />
                              <String fx:value="hover-light-blue" />
                           </styleClass>
                           <graphic>
                              <ImageView fitHeight="30.0" fitWidth="30.0" pickOnBounds="true" preserveRatio="true">
                                 <image>
                                    <Image url="@../assets/images/customers.png" />
                                 </image>
                              </ImageView>
                           </graphic>
                        </Button>
                     </children>
                     <VBox.margin>
                        <Insets bottom="5.0" />
                     </VBox.margin>
                     <padding>
                        <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
                     </padding>
                     <styleClass>
                        <String fx:value="hover-hand" />
                        <String fx:value="hover-light-blue" />
                     </styleClass>
                  </VBox>
                  <VBox alignment="CENTER_LEFT" layoutX="10.0" layoutY="675.0">
                     <children>
                        <Button alignment="BASELINE_LEFT" graphicTextGap="10.0" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Reports">
                           <styleClass>
                              <String fx:value="back-transparent" />
                              <String fx:value="fill-white" />
                              <String fx:value="fn-18" />
                              <String fx:value="hover-hand" />
                              <String fx:value="hover-light-blue" />
                           </styleClass>
                           <graphic>
                              <ImageView fitHeight="30.0" fitWidth="30.0" pickOnBounds="true" preserveRatio="true">
                                 <image>
                                    <Image url="@../assets/images/report.png" />
                                 </image>
                              </ImageView>
                           </graphic>
                        </Button>
                     </children>
                     <VBox.margin>
                        <Insets bottom="5.0" />
                     </VBox.margin>
                     <padding>
                        <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
                     </padding>
                     <styleClass>
                        <String fx:value="hover-hand" />
                        <String fx:value="hover-light-blue" />
                     </styleClass>
                  </VBox>
               </children>
            </VBox>
         </children>
      </HBox>
   </left>
   <bottom>
      <HBox alignment="CENTER" BorderPane.alignment="CENTER">
         <children>
            <Label fx:id="copyrightLabel" alignment="CENTER" prefHeight="17.0" prefWidth="393.0" text="Copyright © 2019 Global Consulting Institution">
               <styleClass>
                  <String fx:value="fill-white" />
                  <String fx:value="fn-14" />
               </styleClass>
            </Label>
         </children>
         <styleClass>
            <String fx:value="back-orange" />
            <String fx:value="fill-white" />
         </styleClass>
      </HBox>
   </bottom>
</BorderPane>
...