Проблема положения компонента JavaFX в SceneBuilder - PullRequest
0 голосов
/ 14 марта 2019

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

<?import javafx.scene.image.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>

<Pane centerShape="false" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" pickOnBounds="false" prefHeight="600.0" prefWidth="800.0" scaleShape="false" styleClass="paneMainPage" stylesheets="@StyleSheets/mainStage_stylesheet.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ControllerMainScene">
   <children>
      <Circle fx:id="internetConnectionCheck" centerY="556.0" fill="#20ff1f" layoutX="735.0" layoutY="31.0" radius="9.0" stroke="BLACK" strokeType="INSIDE" />
      <Slider fx:id="delaySlider" layoutX="14.0" layoutY="568.0" majorTickUnit="1.0" max="10.0" min="1.0" minorTickCount="0" showTickLabels="true" showTickMarks="true" snapToTicks="true" value="1.0">
         <tooltip>
            <Tooltip text="Sets delay time to update currency table" />
         </tooltip>
      </Slider>
      <Text layoutX="14.0" layoutY="564.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Delay (s)" />
      <Button fx:id="exitButton" layoutX="751.0" layoutY="570.0" mnemonicParsing="false" prefHeight="32.0" prefWidth="50.0" text="Exit" />
      <Pane fx:id="dollarCurrencyPane" prefHeight="102.0" prefWidth="140.0">
         <children>
            <Label alignment="CENTER" prefHeight="32.0" prefWidth="140.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="Dollar" />
            <Label alignment="CENTER" layoutY="30.0" prefHeight="18.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="Buy" />
            <Label alignment="CENTER" layoutX="70.0" layoutY="30.0" prefHeight="18.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="Sell" />
            <Label fx:id="dollarBuyLabel" alignment="CENTER" layoutY="48.0" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="0.0" />
            <Label fx:id="dollarSellLabel" alignment="CENTER" layoutX="70.0" layoutY="48.0" minWidth="-Infinity" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="0.0" />
            <Label fx:id="dollarBuyRate" layoutY="73.0" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="\%0.00" />
            <Polygon fx:id="dollarBuyRatePoly" fill="#33FE01" layoutX="60.0" layoutY="53.0" stroke="BLACK" strokeType="INSIDE">
               <points>
                <Double fx:value="-5.0" />
                <Double fx:value="40.0" />
                <Double fx:value="5.0" />
                <Double fx:value="40.0" />
                <Double fx:value="0.0" />
                <Double fx:value="25.0" />
               </points>
            </Polygon>
            <Rectangle fx:id="dollarBuyRateRect" arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="4.0" layoutX="48.0" layoutY="85.0" stroke="BLACK" strokeType="INSIDE" width="18.0" />
            <Label fx:id="dollarSellRate" layoutX="70.0" layoutY="73.0" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="\%0.00" />
            <Polygon fx:id="dollarSellRatePoly" fill="#33FE01" layoutX="130.0" layoutY="53.0" stroke="BLACK" strokeType="INSIDE">
              <points>
                <Double fx:value="-5.0" />
                <Double fx:value="40.0" />
                <Double fx:value="5.0" />
                <Double fx:value="40.0" />
                <Double fx:value="0.0" />
                <Double fx:value="25.0" />
              </points>
            </Polygon>
            <Rectangle fx:id="dollarSellRateRect" arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="4.0" layoutX="118.0" layoutY="85.0" stroke="BLACK" strokeType="INSIDE" width="18.0" />
         </children>
      </Pane>
      <Pane fx:id="euroCurrencyPane" layoutY="101.0" prefHeight="102.0" prefWidth="140.0">
         <children>
            <Label alignment="CENTER" layoutY="-2.0" prefHeight="32.0" prefWidth="140.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="Euro" />
            <Label alignment="CENTER" layoutX="70.0" layoutY="30.0" prefHeight="18.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="Sell" />
            <Label alignment="CENTER" layoutY="30.0" prefHeight="18.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="Buy" />
            <Label fx:id="euroSellLabel" alignment="CENTER" layoutX="70.0" layoutY="48.0" minWidth="-Infinity" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="0.0" />
            <Label fx:id="euroBuyLabel" alignment="CENTER" layoutY="48.0" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="0.0" />
            <Label fx:id="euroSellRate" layoutX="70.0" layoutY="74.0" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="\%0.00" />
            <Label fx:id="euroBuyRate" layoutY="74.0" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="\%0.00" />
            <Rectangle fx:id="euroBuyRateRect" arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="4.0" layoutX="48.0" layoutY="87.0" stroke="BLACK" strokeType="INSIDE" width="18.0" />
            <Polygon fx:id="euroBuyRatePoly" fill="#33FE01" layoutX="60.0" layoutY="55.0" stroke="BLACK" strokeType="INSIDE">
               <points>
                  <Double fx:value="-5.0" />
                  <Double fx:value="40.0" />
                  <Double fx:value="5.0" />
                  <Double fx:value="40.0" />
                  <Double fx:value="0.0" />
                  <Double fx:value="25.0" />
               </points>
            </Polygon>
            <Polygon fx:id="euroSellRatePoly" fill="#33FE01" layoutX="130.0" layoutY="55.0" stroke="BLACK" strokeType="INSIDE">
               <points>
                  <Double fx:value="-5.0" />
                  <Double fx:value="40.0" />
                  <Double fx:value="5.0" />
                  <Double fx:value="40.0" />
                  <Double fx:value="0.0" />
                  <Double fx:value="25.0" />
               </points>
            </Polygon>
            <Rectangle fx:id="euroSellRateRect" arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="4.0" layoutX="118.0" layoutY="87.0" stroke="BLACK" strokeType="INSIDE" width="18.0" />
         </children>
      </Pane>
      <Pane fx:id="gbdCurrencyPane" layoutY="201.0" prefHeight="102.0" prefWidth="140.0">
         <children>
            <Label alignment="CENTER" prefHeight="32.0" prefWidth="140.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="GBP" />
            <Label fx:id="gbpBuyLabel" alignment="CENTER" layoutY="50.0" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="0.0" />
            <Label fx:id="gbpSellLabel" alignment="CENTER" layoutX="70.0" layoutY="50.0" minWidth="-Infinity" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="0.0" />
            <Label alignment="CENTER" layoutY="32.0" prefHeight="18.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="Buy" />
            <Label alignment="CENTER" layoutX="70.0" layoutY="32.0" prefHeight="18.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="Sell" />
            <Label fx:id="gbpBuyRate" layoutY="75.0" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="\%0.00" />
            <Label fx:id="gbpSellRate" layoutX="70.0" layoutY="75.0" prefHeight="26.0" prefWidth="70.0" styleClass="labelCurrencyTable" stylesheets="@StyleSheets/mainStage_stylesheet.css" text="\%0.00" />
            <Rectangle fx:id="gbpSellRateRect" arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="4.0" layoutX="118.0" layoutY="88.0" stroke="BLACK" strokeType="INSIDE" width="18.0" />
            <Polygon fx:id="gbpSellRatePoly" fill="#33FE01" layoutX="130.0" layoutY="56.0" stroke="BLACK" strokeType="INSIDE">
               <points>
                  <Double fx:value="-5.0" />
                  <Double fx:value="40.0" />
                  <Double fx:value="5.0" />
                  <Double fx:value="40.0" />
                  <Double fx:value="0.0" />
                  <Double fx:value="25.0" />
               </points>
            </Polygon>
            <Polygon fx:id="gbpBuyRatePoly" fill="#33FE01" layoutX="60.0" layoutY="56.0" stroke="BLACK" strokeType="INSIDE">
               <points>
                  <Double fx:value="-5.0" />
                  <Double fx:value="40.0" />
                  <Double fx:value="5.0" />
                  <Double fx:value="40.0" />
                  <Double fx:value="0.0" />
                  <Double fx:value="25.0" />
               </points>
            </Polygon>
            <Rectangle fx:id="gbpBuyRateRect" arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="4.0" layoutX="48.0" layoutY="88.0" stroke="BLACK" strokeType="INSIDE" width="18.0" />
         </children>
      </Pane>
   </children>
</Pane>

Изображение.

image

1 Ответ

0 голосов
/ 15 марта 2019

По моему опыту, Scene Builder не является надежным источником для оценки того, как выглядит графический интерфейс. Он всегда обрезает макет по краям большинства внешних элементов, игнорируя любые поля или отступы, которые вы установили для большинства внешних элементов.

Я бы предложил всегда компилировать вашу программу, чтобы увидеть, как она на самом деле выглядит (я знаю, с ней работать медленнее, но гораздо надежнее).

Может быть, ваш класс CSS paneMainPage устанавливает некоторые отступы? Или вы добавляете поля для каждой кнопки в классе CSS внутри mainStage_stylesheet.css?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...