简体   繁体   中英

Scene Builder preview doesn't apply to my Java program (basic calculator)

I'm trying to create a basic calculator UI from a tutorial, I did the followings and it looks great in SceneBuilder but it's all messed up when I run the eclipse... I can't figure out what's causing this.

Calculator in SceneBuilder preview

Calculator when I run the program in Eclipse

The code is built on a VBox, there is one StackPane for a Label, and there are four HBox's in which every HBox contains 4 buttons.

    <VBox maxHeight="-Infinity" maxWidth="300.0" minHeight="300.0" minWidth="-Infinity" prefHeight="300.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <StackPane prefHeight="75.0" prefWidth="10.0" >
         <children>
            <Label prefHeight="38.0" prefWidth="327.0" text="LABEL">
               <font>
                  <Font name="System Bold" size="18.0" />
               </font>
            </Label>
         </children></StackPane>
      <HBox alignment="CENTER" prefHeight="50.0" prefWidth="300.0" spacing="10.0">
         <children>
            <Button mnemonicParsing="false" prefWidth="50.0" text="7">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
            <Button mnemonicParsing="false" prefWidth="50.0" text="8">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
            <Button mnemonicParsing="false" prefWidth="50.0" text="9">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
            <Button mnemonicParsing="false" prefWidth="50.0" text="/">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
         </children>
      </HBox>
      <HBox alignment="CENTER" prefHeight="50.0" prefWidth="300.0" spacing="10.0">
         <children>
            <Button mnemonicParsing="false" prefWidth="50.0" text="4">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
            <Button mnemonicParsing="false" prefWidth="50.0" text="5">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
            <Button mnemonicParsing="false" prefWidth="50.0" text="6">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
            <Button mnemonicParsing="false" prefWidth="50.0" text="*">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
         </children>
      </HBox>
      <HBox alignment="CENTER" prefHeight="50.0" prefWidth="300.0" spacing="10.0">
         <children>
            <Button mnemonicParsing="false" prefWidth="50.0" text="3">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
            <Button mnemonicParsing="false" prefWidth="50.0" text="2">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
            <Button mnemonicParsing="false" prefWidth="50.0" text="1">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
            <Button mnemonicParsing="false" prefWidth="50.0" text="-">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
         </children>
      </HBox>
      <HBox alignment="CENTER" prefHeight="50.0" prefWidth="300.0" spacing="10.0">
         <children>
            <Button mnemonicParsing="false" prefWidth="110.0" text="0">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
            <Button mnemonicParsing="false" prefWidth="50.0" text="=">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
            <Button mnemonicParsing="false" prefWidth="50.0" text="+">
               <font>
                  <Font size="18.0" />
               </font>
            </Button>
         </children>
      </HBox>
   </children>
</VBox>

Ok I solved it. It was simply because I was trying to Run different project lol. I had a project I was working on before and I guess I'm still a newbie..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM