AnchorPane在不同的屏幕上调整大小JavaFX

时间:2017-08-03 11:01:40

标签: javafx

我有一个关于Anchor Pane大小调整的问题。我在我的计算机上创建了一个关于JavaFX的大型项目,实际上,它的屏幕比我的笔记本电脑大。我的笔记本电脑是15.7'我的电脑屏幕是32'我在每个fxml中都使用了Anchor Pane作为我的父布局,然后是窗格,然后是他们的孩子。

我已经将Anchor Pane Constraints应用于每个孩子和每个方面,因为' 0'但我的布局重叠。不知道为什么。我希望它能在我的笔记本电脑上调整大小。有什么办法或者我是否应该使用Scene Builder手动调整每个页面的大小?我在应用Anchor Pane Constraints之前和之后向您展示了一页。

Admin_Page.fxml

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

<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXDrawer?>
<?import com.jfoenix.controls.JFXHamburger?>
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?>

<AnchorPane id="AnchorPane" fx:id="anchorPane" prefHeight="763.0" prefWidth="1213.0" stylesheets="@style.css" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="schoolmanagementsystem.Admin_PageController">
   <children>
      <Pane layoutY="-2.0" prefHeight="66.0" prefWidth="1213.0" style="-fx-background-color: #39B7CD;" AnchorPane.topAnchor="0.0">
         <children>
            <JFXHamburger id="hamburger" fx:id="hamburger" layoutY="11.0" prefHeight="32.0" prefWidth="57.0" stylesheets="@style.css" />
            <Label layoutX="301.0" layoutY="9.0" prefHeight="48.0" prefWidth="660.0" text="                            Happy Palace Grammer School" textAlignment="CENTER" textFill="#ece9ef">
               <font>
                  <Font name="Cooper Black" size="24.0" />
               </font>
            </Label>
         </children>
      </Pane>
      <Pane layoutY="64.0" prefHeight="54.0" prefWidth="1213.0" style="-fx-background-color: #33A1DE;">
         <children>
            <Label fx:id="time" layoutX="527.0" layoutY="11.0" prefHeight="32.0" prefWidth="159.0" textFill="WHITE">
               <font>
                  <Font name="Cooper Black" size="18.0" />
               </font></Label>
            <ImageView fitHeight="41.0" fitWidth="69.0" layoutX="907.0" layoutY="7.0" pickOnBounds="true" preserveRatio="true">
               <image>
                  <Image url="@Me.jpg" />
               </image>
               <effect>
                  <DropShadow />
               </effect>
            </ImageView>
            <Label layoutX="980.0" layoutY="7.0" prefHeight="41.0" prefWidth="219.0" text="Logged In : Syed Bilal" textFill="#ece9ef">
               <font>
                  <Font name="Cooper Black" size="18.0" />
               </font>
            </Label>
         </children></Pane>
      <AnchorPane fx:id="content" layoutX="180.0" layoutY="114.0" prefHeight="766.0" prefWidth="1032.0" stylesheets="@style.css">
         <children>
            <ImageView fitHeight="763.0" fitWidth="1213.0" layoutX="-180.0" layoutY="2.0" pickOnBounds="true" AnchorPane.topAnchor="2.0">
               <image>
                  <Image url="@Main%20Background.png" />
               </image></ImageView>
            <Pane layoutX="36.0" layoutY="47.0" prefHeight="56.0" prefWidth="907.0" style="-fx-background-color: #2E8B57;">
               <children>
                  <Label layoutX="394.0" layoutY="12.0" prefHeight="32.0" prefWidth="138.0" text="Admin Page" textFill="WHITE">
                     <font>
                        <Font name="System Bold" size="22.0" />
                     </font>
                  </Label>
               </children>
            </Pane>
            <JFXDrawer fx:id="drawer" defaultDrawerSize="190.0" layoutX="-180.0" layoutY="3.0" prefHeight="763.0" prefWidth="180.0" />
            <JFXButton id="MainIcons" alignment="BOTTOM_CENTER" buttonType="RAISED" contentDisplay="TOP" layoutX="193.0" layoutY="178.0" onAction="#LoadFees" prefHeight="165.0" prefWidth="189.0" ripplerFill="WHITE" text="Fees" textFill="#fcf8f8" wrapText="true">
               <cursor>
                  <Cursor fx:constant="HAND" />
               </cursor>
               <font>
                  <Font name="System Bold" size="20.0" />
               </font>
               <graphic>
                  <FontAwesomeIconView fontSmoothingType="LCD" glyphName="FOLDER" size="100" smooth="false">
                     <effect>
                        <DropShadow />
                     </effect>
                     <cursor>
                        <Cursor fx:constant="HAND" />
                     </cursor>
                  </FontAwesomeIconView>
               </graphic>
            </JFXButton>
            <JFXButton id="MainIcons" alignment="BOTTOM_CENTER" buttonType="RAISED" contentDisplay="TOP" layoutX="611.0" layoutY="178.0" onAction="#LoadFaculty" prefHeight="165.0" prefWidth="189.0" text="Faculty" textFill="#fcf8f8">
               <cursor>
                  <Cursor fx:constant="HAND" />
               </cursor>
               <font>
                  <Font name="System Bold" size="20.0" />
               </font>
               <graphic>
                  <FontAwesomeIconView fontSmoothingType="LCD" glyphName="FILE" size="100">
                     <cursor>
                        <Cursor fx:constant="HAND" />
                     </cursor>
                     <effect>
                        <DropShadow />
                     </effect>
                  </FontAwesomeIconView>
               </graphic>
            </JFXButton>
            <JFXButton id="MainIcons" alignment="BOTTOM_CENTER" buttonType="RAISED" contentDisplay="TOP" layoutX="193.0" layoutY="428.0" onAction="#LoadAdmission" prefHeight="165.0" prefWidth="189.0" text="Admission" textFill="#fcf8f8">
               <cursor>
                  <Cursor fx:constant="HAND" />
               </cursor>
               <font>
                  <Font name="System Bold" size="20.0" />
               </font>
               <graphic>
                  <FontAwesomeIconView fontSmoothingType="LCD" glyphName="BUYSELLADS" size="100">
                     <cursor>
                        <Cursor fx:constant="HAND" />
                     </cursor>
                     <effect>
                        <DropShadow />
                     </effect>
                  </FontAwesomeIconView>
               </graphic>
            </JFXButton>
            <JFXButton id="MainIcons" alignment="BOTTOM_CENTER" buttonType="RAISED" contentDisplay="TOP" layoutX="611.0" layoutY="428.0" onAction="#LoadAdmin" prefHeight="165.0" prefWidth="189.0" text="Admin" textFill="#fcf8f8">
               <cursor>
                  <Cursor fx:constant="HAND" />
               </cursor>
               <font>
                  <Font name="System Bold" size="20.0" />
               </font>
               <graphic>
                  <FontAwesomeIconView fontSmoothingType="LCD" glyphName="DESKTOP" size="100">
                     <cursor>
                        <Cursor fx:constant="HAND" />
                     </cursor>
                     <effect>
                        <DropShadow />
                     </effect>
                  </FontAwesomeIconView>
               </graphic>
            </JFXButton>
         </children>
      </AnchorPane>
   </children>
</AnchorPane>

Before Applying any constraints

I have selected controls on which I have applied Anchor Pane Constraints on every side as 0

0 个答案:

没有答案
相关问题