我在Eclipse、IntelliJ和Netbeans上使用JavaFX在Gluon Scene Builder中创建的GUI显示时遇到了问题

我在Eclipse、IntelliJ和Netbeans上使用JavaFX在Gluon Scene Builder中创建的GUI显示时遇到了问题,java,javafx,Java,Javafx,我已经包括了我使用Gluon场景生成器创建的sample.fxml。 我面临的问题是,每当我作为JavaFX项目运行时,我只会得到一个空白屏幕 <?xml version="1.0" encoding="UTF-8"?> <?import javafx.geometry.Insets?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.Label?> &l

我已经包括了我使用Gluon场景生成器创建的sample.fxml。 我面临的问题是,每当我作为JavaFX项目运行时,我只会得到一个空白屏幕

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

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.effect.Glow?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?>

<BorderPane id="login" blendMode="SOFT_LIGHT" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" style="-fx-background-color: gray;" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
   <left>
      <Pane prefHeight="299.0" prefWidth="200.0" BorderPane.alignment="CENTER">
         <children>
            <Label id="username_label" alignment="CENTER" contentDisplay="CENTER" layoutX="72.0" layoutY="57.0" prefHeight="35.0" prefWidth="100.0" style="-fx-background-color: wheat; -fx-border-color: brown;" text="username">
               <font>
                  <Font name="Wawati SC Regular" size="16.0" />
               </font>
               <padding>
                  <Insets bottom="5.0" left="15.0" right="8.0" top="5.0" />
               </padding>
            </Label>
            <Label id="password_label" alignment="CENTER" contentDisplay="CENTER" layoutX="72.0" layoutY="141.0" prefHeight="35.0" prefWidth="100.0" style="-fx-background-color: wheat; -fx-border-color: brown;" text="password" textAlignment="CENTER">
               <font>
                  <Font name="Wawati SC Regular" size="16.0" />
               </font>
               <padding>
                  <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
               </padding>
            </Label>
         </children>
      </Pane>
   </left>
   <center>
      <Pane prefHeight="316.0" prefWidth="371.0" BorderPane.alignment="CENTER">
         <children>
            <TextField id="username_tField" alignment="CENTER" layoutX="14.0" layoutY="59.0" prefHeight="30.0" prefWidth="230.0" promptText="Enter username here" style="-fx-background-color: gray;">
               <padding>
                  <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
               </padding>
               <font>
                  <Font name="Courier Oblique" size="14.0" />
               </font>
               <effect>
                  <Glow />
               </effect>
            </TextField>
            <PasswordField id="password_tField" alignment="CENTER" layoutX="14.0" layoutY="143.0" prefHeight="30.0" prefWidth="230.0" promptText="Enter password here" style="-fx-background-color: gray;">
               <padding>
                  <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
               </padding>
               <font>
                  <Font name="Courier Oblique" size="14.0" />
               </font>
               <effect>
                  <Glow />
               </effect>
            </PasswordField>
            <Pane layoutX="62.0" layoutY="216.0" prefHeight="57.0" prefWidth="182.0" style="-fx-background-color: gray;">
               <children>
                  <Button id="login_Button" alignment="CENTER" contentDisplay="RIGHT" layoutX="75.0" layoutY="11.0" mnemonicParsing="false" prefHeight="35.0" prefWidth="95.0" style="-fx-background-color: wheat; -fx-border-color: brown;" text="Login" textAlignment="CENTER">
                     <font>
                        <Font name="Wawati SC Regular" size="16.0" />
                     </font>
                     <opaqueInsets>
                        <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
                     </opaqueInsets>
                     <padding>
                        <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
                     </padding>
                  </Button>
               </children>
            </Pane>
         </children>
      </Pane>
   </center>
   <top>
      <Pane id="login_title" prefHeight="84.0" prefWidth="600.0" BorderPane.alignment="CENTER">
         <children>
            <Label id="login_title" alignment="CENTER" contentDisplay="CENTER" layoutX="114.0" layoutY="28.0" prefHeight="46.0" prefWidth="341.0" style="-fx-background-color: gray;" text="Welcome to Real Estate World ...">
               <padding>
                  <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
               </padding>
               <font>
                  <Font name="Wawati SC Regular" size="24.0" />
               </font>
               <opaqueInsets>
                  <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
               </opaqueInsets>
            </Label>
         </children>
      </Pane>
   </top>
</BorderPane>

当我尝试安装e(fx)eclipse时,eclipse在加载19%时冻结,并且没有一个版本可以在我的yosemite mac上运行。另外,当我试图从上面的fxml文件加载GUI时,我得到一个空白屏幕

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

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.effect.Glow?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?>

<BorderPane id="login" blendMode="SOFT_LIGHT" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" style="-fx-background-color: gray;" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
   <left>
      <Pane prefHeight="299.0" prefWidth="200.0" BorderPane.alignment="CENTER">
         <children>
            <Label id="username_label" alignment="CENTER" contentDisplay="CENTER" layoutX="72.0" layoutY="57.0" prefHeight="35.0" prefWidth="100.0" style="-fx-background-color: wheat; -fx-border-color: brown;" text="username">
               <font>
                  <Font name="Wawati SC Regular" size="16.0" />
               </font>
               <padding>
                  <Insets bottom="5.0" left="15.0" right="8.0" top="5.0" />
               </padding>
            </Label>
            <Label id="password_label" alignment="CENTER" contentDisplay="CENTER" layoutX="72.0" layoutY="141.0" prefHeight="35.0" prefWidth="100.0" style="-fx-background-color: wheat; -fx-border-color: brown;" text="password" textAlignment="CENTER">
               <font>
                  <Font name="Wawati SC Regular" size="16.0" />
               </font>
               <padding>
                  <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
               </padding>
            </Label>
         </children>
      </Pane>
   </left>
   <center>
      <Pane prefHeight="316.0" prefWidth="371.0" BorderPane.alignment="CENTER">
         <children>
            <TextField id="username_tField" alignment="CENTER" layoutX="14.0" layoutY="59.0" prefHeight="30.0" prefWidth="230.0" promptText="Enter username here" style="-fx-background-color: gray;">
               <padding>
                  <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
               </padding>
               <font>
                  <Font name="Courier Oblique" size="14.0" />
               </font>
               <effect>
                  <Glow />
               </effect>
            </TextField>
            <PasswordField id="password_tField" alignment="CENTER" layoutX="14.0" layoutY="143.0" prefHeight="30.0" prefWidth="230.0" promptText="Enter password here" style="-fx-background-color: gray;">
               <padding>
                  <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
               </padding>
               <font>
                  <Font name="Courier Oblique" size="14.0" />
               </font>
               <effect>
                  <Glow />
               </effect>
            </PasswordField>
            <Pane layoutX="62.0" layoutY="216.0" prefHeight="57.0" prefWidth="182.0" style="-fx-background-color: gray;">
               <children>
                  <Button id="login_Button" alignment="CENTER" contentDisplay="RIGHT" layoutX="75.0" layoutY="11.0" mnemonicParsing="false" prefHeight="35.0" prefWidth="95.0" style="-fx-background-color: wheat; -fx-border-color: brown;" text="Login" textAlignment="CENTER">
                     <font>
                        <Font name="Wawati SC Regular" size="16.0" />
                     </font>
                     <opaqueInsets>
                        <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
                     </opaqueInsets>
                     <padding>
                        <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
                     </padding>
                  </Button>
               </children>
            </Pane>
         </children>
      </Pane>
   </center>
   <top>
      <Pane id="login_title" prefHeight="84.0" prefWidth="600.0" BorderPane.alignment="CENTER">
         <children>
            <Label id="login_title" alignment="CENTER" contentDisplay="CENTER" layoutX="114.0" layoutY="28.0" prefHeight="46.0" prefWidth="341.0" style="-fx-background-color: gray;" text="Welcome to Real Estate World ...">
               <padding>
                  <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
               </padding>
               <font>
                  <Font name="Wawati SC Regular" size="24.0" />
               </font>
               <opaqueInsets>
                  <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
               </opaqueInsets>
            </Label>
         </children>
      </Pane>
   </top>
</BorderPane>

非常感谢您在这个问题上提供帮助。

边框窗格的
blendMode
有一个问题:它被设置为
“软光”

顺便说一句,调试此类问题的一个非常有用的工具是——它允许在运行时分析JavaFX场景图,甚至修改节点的属性

<BorderPane id="login" maxHeight="-Infinity" ...
package afester.javafx.examples.fxml;

import java.net.URL;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class FxmlViewer extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
       URL location = getClass().getResource("FxmlSample.fxml");
       BorderPane root = FXMLLoader.load(location);
       stage.setScene(new Scene(root));
       stage.show();
    }
}