1

I am trying to open FXML File with Scene Builder using eclipse. I right-clicked the fxml file and click the 'Open with SceneBuilder' button. However, the scene builder does not opening. Then I tried to create a new project and create a new fxml document. The scenebuilder open the new fxml file. I guess what is wrong is the file itself.

This is my fxml file.

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

<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.effect.InnerShadow?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.Line?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane minHeight="600.0" minWidth="900.0" prefHeight="600.0" prefWidth="900.0" style="-fx-background-color: black;" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainController">
   <children>
      <BorderPane prefHeight="600.0" prefWidth="900.0">
         <center>
            <Pane prefHeight="612.0" prefWidth="900.0" style="-fx-background-color: #0A1021;" BorderPane.alignment="CENTER">
               <children>
                  <ImageView fitHeight="607.0" fitWidth="660.0" layoutX="-201.0" layoutY="1.0" pickOnBounds="true" preserveRatio="true" style="-fx-opacity: 0.1;">
                     <image>
                        <Image url="@../img/login_background2.jpg" />
                     </image>
                  </ImageView>
                  <Button fx:id="login_button_1" layoutX="617.0" layoutY="327.0" lineSpacing="1.0" mnemonicParsing="false" onAction="#login_button1" prefHeight="55.0" prefWidth="126.0" text="LOGIN" textAlignment="CENTER" textFill="WHITE">
                     <font>
                        <Font name="Roboto Black" size="19.0" />
                     </font>
                     <cursor>
                        <Cursor fx:constant="HAND" />
                     </cursor>
                  </Button>
                  <ImageView fitHeight="216.0" fitWidth="230.0" layoutX="118.0" layoutY="114.0" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../img/PCMS_logo.png" />
                     </image>
                  </ImageView>
                  <Text fill="WHITE" layoutX="125.0" layoutY="377.0" strokeType="OUTSIDE" strokeWidth="0.0" text="deFurtura">
                     <font>
                        <Font name="SansSerif Bold" size="46.0" />
                     </font>
                  </Text>
                  <Text fill="WHITE" layoutX="128.0" layoutY="402.0" strokeType="OUTSIDE" strokeWidth="0.0" text="beyond common furniture">
                     <font>
                        <Font name="SansSerif Bold Italic" size="17.0" />
                     </font>
                  </Text>
                  <Text fill="WHITE" layoutX="594.0" layoutY="251.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Hello!">
                     <font>
                        <Font name="Roboto" size="36.0" />
                     </font>
                  </Text>
                  <Text fill="WHITE" layoutX="594.0" layoutY="286.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Let's get started">
                     <font>
                        <Font name="Roboto" size="24.0" />
                     </font>
                  </Text>
                  <Button fx:id="exit_button" layoutX="870.0" layoutY="1.0" mnemonicParsing="false" onAction="#exit_button_action" prefHeight="20.0" prefWidth="20.0">
                     <graphic>
                        <FontAwesomeIconView fx:id="exit_icon" fill="WHITE" glyphName="TIMES_CIRCLE" size="18" />
                     </graphic>
                     <cursor>
                        <Cursor fx:constant="HAND" />
                     </cursor>
                  </Button>
               </children>
            </Pane>
         </center>
      </BorderPane>
      <Pane fx:id="login_pane" layoutX="932.0" layoutY="86.0" prefHeight="429.0" prefWidth="308.0" style="-fx-background-color: White; -fx-background-radius: 10; -fx-opacity: 1;">
         <children>
            <Text layoutX="104.0" layoutY="78.0" strokeType="OUTSIDE" strokeWidth="0.0" text="LOGIN">
               <font>
                  <Font name="Roboto Black" size="34.0" />
               </font>
            </Text>
            <Button fx:id="cancel_button" layoutX="264.0" layoutY="14.0" mnemonicParsing="false" onAction="#cancel_button_action" prefHeight="26.0" prefWidth="13.0">
               <graphic>
                  <FontAwesomeIconView fx:id="cancel_icon" fill="#aeaeae" glyphName="TIMES_CIRCLE" size="16" />
               </graphic>
               <cursor>
                  <Cursor fx:constant="HAND" />
               </cursor>
            </Button>
            <Line endX="135.0" layoutX="154.0" layoutY="101.0" startX="-135.0" />
            <VBox alignment="TOP_CENTER" layoutX="42.0" layoutY="115.0" prefHeight="289.0" prefWidth="229.0">
               <children>
                  <Label fx:id="login_label_status" prefHeight="54.0" prefWidth="208.0" style="-fx-border-style: solid; -fx-border-color: #e44040; -fx-border-width: 1; -fx-background-color: #FF7D7A; -fx-border-radius: 10; -fx-background-radius: 10;" text="Login Unsuccessful !&#10;The username or password is &#10;incorrect!" textFill="#e44040" visible="false">
                     <padding>
                        <Insets bottom="5.0" left="10.0" right="10.0" top="2.0" />
                     </padding>
                     <font>
                        <Font name="Roboto" size="13.0" />
                     </font>
                  </Label>
                  <Pane prefHeight="236.0" prefWidth="229.0">
                     <children>
                        <TextField fx:id="login_username" layoutX="11.0" layoutY="14.0" prefHeight="35.0" prefWidth="208.0" promptText=" Username">
                           <padding>
                              <Insets left="10.0" />
                           </padding>
                           <opaqueInsets>
                              <Insets />
                           </opaqueInsets>
                           <cursor>
                              <Cursor fx:constant="TEXT" />
                           </cursor>
                           <effect>
                              <InnerShadow height="3.21" radius="1.105" width="3.21" />
                           </effect>
                        </TextField>
                        <PasswordField fx:id="login_password" layoutX="11.0" layoutY="69.0" prefHeight="35.0" prefWidth="208.0" promptText=" Password" />
                        <Button fx:id="login_button_2" layoutX="47.0" layoutY="127.0" mnemonicParsing="false" onAction="#login_action" prefHeight="40.0" prefWidth="135.0" text="LOGIN" textFill="WHITE">
                           <font>
                              <Font name="Roboto Black" size="15.0" />
                           </font>
                           <cursor>
                              <Cursor fx:constant="HAND" />
                           </cursor>
                        </Button>
                        <FontAwesomeIconView fill="#bcb8b8" glyphName="USER" layoutX="196.0" layoutY="37.0" size="18" />
                        <FontAwesomeIconView fill="#bcb8b8" glyphName="UNLOCK_ALT" layoutX="196.0" layoutY="92.0" size="18" />
                     </children>
                  </Pane>
               </children>
            </VBox>
         </children>
         <effect>
            <DropShadow height="15.0" radius="7.0" width="15.0" />
         </effect>
      </Pane>
   </children>
</AnchorPane>
  • You have third-party library classes in your FXML file which Scene Builder is not aware of. It works in Eclipse because the IDE knows everything about your project, including which dependencies you've added. Scene Builder is not as sophisticated. However, you can add libraries to Scene Builder. Open the "JAR/FXML Manager" and add the library. – Slaw Oct 30 '19 at 13:55
  • This gives an example of adding a library to Scene Builder: https://stackoverflow.com/questions/29601190/include-controls-fx-in-scene-builder – Slaw Oct 30 '19 at 14:17

2 Answers2

1

Probably you are using scene builder version 11+, and font awesome is not supported in that particular version.

You can try unistall your current scene builder and install scene builder 8.x

Hope this fix your problem

0

The problem is here <?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>. Its not being recognized. Maybe you can try this How to use font awesome in a fxml project (javafx)

rhenesys
  • 174
  • 1
  • 11