Member 13476370 Ответов: 0

Унификация стилей в построителе сцен и реальном приложении


Я новичок в javaFX и потратил много времени на разработку графического интерфейса калькулятора на "Scene Builder 2.0" и установку подходящего размера для каждого элемента на сцене . Однако при запуске проекта на eclipse размеры отличаются, и текст на "textField" и `Label` не будет отображаться, и это очень важно, потому что я не могу проверить логику калькулятора !!

> То, что я пробовал

- установка размеров в USE_PREF_SIZE
но это не сработало.
ниже приведены изображения обоих :

>на затмении : https://ibb.co/dxk7cn

>on scene Builder : https://ibb.c

Что я уже пробовал:

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

<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import javafx.geometry.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>

<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="320.0" style="-fx-background-color: #17202A;" type="AnchorPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Controller">
   <children>
      <GridPane layoutX="6.0" layoutY="161.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="300.0" prefWidth="314.0" style="-fx-background-color: #17202A;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="3.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="200.0">
        <columnConstraints>
            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
          <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
          <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
        </columnConstraints>
        <rowConstraints>
            <RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
            <RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
          <RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
          <RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
          <RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
        </rowConstraints>
         <children>
            <Button fx:id="equals" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#equalsClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #48C9B0;" text="=" textFill="#c31d1d" GridPane.columnIndex="3" GridPane.rowIndex="4">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
               <font>
                  <Font size="24.0" />
               </font>
            </Button>
            <Button fx:id="point" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#pointClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="." GridPane.columnIndex="2" GridPane.rowIndex="4">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="zero" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#zeroClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="0" GridPane.columnIndex="1" GridPane.rowIndex="4">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="modulo" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#moduloClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="\%" GridPane.rowIndex="4">
               <padding>
                  <Insets bottom="1.0" />
               </padding>
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="plus" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#plusClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #E74C3C;" text="+" GridPane.columnIndex="3" GridPane.rowIndex="3">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="three" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#threeClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="3" GridPane.columnIndex="2" GridPane.rowIndex="3">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="two" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#twoClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="2" GridPane.columnIndex="1" GridPane.rowIndex="3">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="one" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#oneClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="1" GridPane.rowIndex="3">
               <padding>
                  <Insets bottom="1.0" />
               </padding>
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="divide" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#divideClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #E74C3C;" text="/" GridPane.columnIndex="3" GridPane.rowIndex="2">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="six" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#sixClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="6" GridPane.columnIndex="2" GridPane.rowIndex="2">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="five" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#fiveClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="5" GridPane.columnIndex="1" GridPane.rowIndex="2">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="four" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#fourClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="4" GridPane.rowIndex="2">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="multiply" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#timesClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #E74C3C;" text="*" GridPane.columnIndex="3" GridPane.rowIndex="1">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="nine" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#nineClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="9" GridPane.columnIndex="2" GridPane.rowIndex="1">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
               <padding>
                  <Insets bottom="3.0" left="3.0" right="3.0" />
               </padding>
            </Button>
            <Button fx:id="eight" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#eightClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="8" GridPane.columnIndex="1" GridPane.rowIndex="1">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
               <padding>
                  <Insets bottom="3.0" left="3.0" right="3.0" />
               </padding>
            </Button>
            <Button fx:id="seven" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#sevenClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="7" GridPane.rowIndex="1">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
            </Button>
            <Button fx:id="minus" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#minusClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #E74C3C;" text="-" GridPane.columnIndex="3">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
               <font>
                  <Font name="Britannic Bold" size="21.0" />
               </font>
            </Button>
            <Button fx:id="previous" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#prevClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="PREV" GridPane.columnSpan="3">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
               <font>
                  <Font name="Britannic Bold" size="21.0" />
               </font>
               <padding>
                  <Insets left="3.0" />
               </padding>
            </Button>
            <Button fx:id="clear" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#clearClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="CE" GridPane.columnIndex="2">
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
               <font>
                  <Font size="22.0" />
               </font>
            </Button>
            <Button fx:id="next" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#nextClicked" prefHeight="50.0" prefWidth="70.0" style="-fx-background-color: #ffffb3;" text="NEXT" GridPane.columnIndex="1">
               <padding>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </padding>
               <GridPane.margin>
                  <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
               </GridPane.margin>
               <font>
                  <Font name="Britannic Bold" size="21.0" />
               </font>
            </Button>
         </children>
      </GridPane>
      <Label fx:id="displayLabel" layoutX="5.0" layoutY="51.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="50.0" prefWidth="308.0" style="-fx-background-color: #eee9e9;" textFill="#3c3232" AnchorPane.bottomAnchor="400.0" AnchorPane.leftAnchor="3.0" AnchorPane.rightAnchor="3.0" AnchorPane.topAnchor="3.0">
         <font>
            <Font size="18.0" />
         </font></Label>
      <TextField fx:id="inputTextField" alignment="CENTER_RIGHT" layoutX="114.0" layoutY="104.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" nodeOrientation="LEFT_TO_RIGHT" prefHeight="96.0" prefWidth="314.0" style="-fx-background-color: #17202A;" text="rrrro" AnchorPane.bottomAnchor="300.0" AnchorPane.leftAnchor="3.0" AnchorPane.rightAnchor="3.0" AnchorPane.topAnchor="104.0">
         <font>
            <Font size="22.0" />
         </font></TextField>
   </children>
</fx:root>

0 Ответов