首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JavaFX FXMLLoader无效属性

JavaFX FXMLLoader无效属性
EN

Stack Overflow用户
提问于 2014-01-21 16:03:14
回答 1查看 4K关注 0票数 3

我希望在Swing上下文中使用JavaFX 2来获得一些帮助。我用场景生成器(版本:2.0b10,Changeset: 48fc80a12d33)构建了一个场景,并试图简单地将其加载到Java1.7下的Swing JFXPanel上。当我这样做时,我会在第16行得到一个无效的属性错误。

以下是整个场景:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>

<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="600.0" minWidth="800.0" prefHeight="768.0" prefWidth="1024.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
    <children>
        <BorderPane layoutX="54.0" layoutY="45.0" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
            <left>
                <VBox fx:id="" prefHeight="726.0" prefWidth="210.0" style="-fx-background-color: #dee8f6;">
                    <children>
                        <Label style="-fx-font-weight: bold;" text="Storage Overview Home" VBox.vgrow="NEVER">
                            <padding>
                                <Insets bottom="18.0" left="6.0" top="6.0" />
                            </padding>
                        </Label>
                        <ComboBox fx:id="ASPCombo" prefWidth="150.0" VBox.vgrow="NEVER" xmlns:fx="http://javafx.com/fxml">
                            <VBox.margin>
                                <Insets bottom="12.0" left="6.0" />
                            </VBox.margin>
                        </ComboBox>
                        <Label text="Job Information" VBox.vgrow="NEVER" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
                            <padding>
                                <Insets bottom="12.0" left="6.0" />
                            </padding>
                        </Label>
                        <Hyperlink fx:id="activeJobStatusLink" style="-fx-text-fill: #210B61;" text="Active Job Status" VBox.vgrow="NEVER" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
                            <VBox.margin>
                                <Insets left="12.0" />
                            </VBox.margin>
                        </Hyperlink>
                        <Hyperlink fx:id="jobMonitorThresholdLink" style="-fx-text-fill: #210B61;" text="Job Monitor Threshold History" VBox.vgrow="NEVER" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
                            <VBox.margin>
                                <Insets left="12.0" />
                            </VBox.margin>
                        </Hyperlink>
                        <Hyperlink fx:id="jobQtempThresholdLink" style="-fx-text-fill: #210B61;" text="Job QTEMP Threshold History" VBox.vgrow="NEVER" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
                            <VBox.margin>
                                <Insets left="12.0" />
                            </VBox.margin>
                        </Hyperlink>
                        <Hyperlink fx:id="jobSpooledFileThresholdLink" style="-fx-text-fill: #210B61;" text="Job Spooled File Threshold History" VBox.vgrow="NEVER" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
                            <VBox.margin>
                                <Insets left="12.0" />
                            </VBox.margin>
                        </Hyperlink>
                        <StackPane prefHeight="150.0" prefWidth="200.0" VBox.vgrow="ALWAYS" />
                        <Label text="See Also">
                            <padding>
                                <Insets bottom="6.0" left="12.0" />
                            </padding>
                        </Label>
                        <Hyperlink fx:id="collectionHistoryLink" style="-fx-text-fill: #210B61;" text="Collection History" VBox.vgrow="NEVER" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
                            <VBox.margin>
                                <Insets left="12.0" />
                            </VBox.margin>
                        </Hyperlink>
                        <Hyperlink fx:id="currentStorageLink" style="-fx-text-fill: #210B61;" text="Current Storage" VBox.vgrow="NEVER" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
                            <VBox.margin>
                                <Insets bottom="12.0" left="12.0" />
                            </VBox.margin>
                        </Hyperlink>
                    </children>
                </VBox>
            </left>
            <top>
                <ToolBar prefWidth="200.0" xmlns:fx="http://javafx.com/fxml">
                    <items>
                        <Button fx:id="btnRefresh" mnemonicParsing="false" text="Back" />
                        <HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
                            <children>
                                <Pane HBox.hgrow="ALWAYS" />
                            </children>
                        </HBox>
                        <Button mnemonicParsing="false" text="Refresh" />
                    </items>
                </ToolBar>
            </top>
            <center>
                <VBox prefHeight="200.0" prefWidth="100.0" style="-fx-background-color: #FFFFFF;">
                    <children>
                        <VBox minHeight="-Infinity" prefHeight="136.0" prefWidth="766.0" VBox.vgrow="NEVER">
                            <children>
                                <Label fx:id="storageOverviewTitle" style="-fx-font-size: 18; -fx-text-fill: #0000FF;" text="Identify and Solve Disk Storage Problems" VBox.vgrow="NEVER">
                                    <textFill>
                                        <Color blue="1.0" />
                                    </textFill>
                                </Label>
                                <TextArea fx:id="storageOverviewTextArea" editable="false" prefHeight="100.0" prefWidth="200.0" text="The Storage Overview helps you quickly identify and solve disk storage problems. Most surges in disk use are caused by active jobs. For example, a server communication job can devour a large amount of your unprotected storage space. And, these jobs can be hard to find.  Use the ASP Threshold History and Job Temp Storage History buttons to display the ASPs and jobs that have exceeded their thresholds. Use the Active Jobs Status button to find and hold or end the job(s) causing a disk storage problem." wrapText="true" VBox.vgrow="NEVER" />
                            </children>
                            <VBox.margin>
                                <Insets bottom="24.0" left="24.0" right="24.0" top="24.0" />
                            </VBox.margin>
                        </VBox>
                        <HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="177.0" prefWidth="814.0" VBox.vgrow="NEVER">
                            <children>
                                <PieChart fx:id="totalASPUtilizationPieChart" title="Total ASP Utilization" HBox.hgrow="NEVER" />
                                <PieChart fx:id="utilizationByLibraryPieChart" title="By Library" HBox.hgrow="NEVER" />
                                <PieChart fx:id="utilizationByIFSDirPieChart" title="By IFS Directory" HBox.hgrow="NEVER" />
                            </children>
                        </HBox>
                        <AreaChart fx:id="ASPUtilizationHistoryAreaChart" title="Utilization History - ASP 001" VBox.vgrow="ALWAYS">
                            <xAxis>
                                <CategoryAxis side="BOTTOM" />
                            </xAxis>
                            <yAxis>
                                <NumberAxis side="LEFT" />
                            </yAxis>
                        </AreaChart>
                    </children>
                </VBox>
            </center>
        </BorderPane>
    </children>
</AnchorPane>

我用来显示场景图的代码是:

代码语言:javascript
复制
Platform.setImplicitExit(false);
Platform.runLater(new Runnable() {
    @Override
    public void run() {
        Parent root;
        try {
            root = FXMLLoader.load(getClass().getResource("MyPanel.fxml"));
            Scene scene = new Scene(root);
            swingPanel.setScene(scene);
        } catch (Exception ex){
            //Log an error here...
        }
    }
});

我得到的错误是:

代码语言:javascript
复制
Invalid property.
/C:/HelpSys/space/trunk/gui/classes/com/helpsystems/space/gui/csi/MyPanel.fxml:16
  at javafx.fxml.FXMLLoader$PropertyElement.<init>(FXMLLoader.java:1154)
  at javafx.fxml.FXMLLoader.createElement(FXMLLoader.java:2338)
  at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2311)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2131)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
  at com.helpsystems.space.gui.csi.CSIWizzard$1.run(CSIWizzard.java:182)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
  at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
  at java.lang.Thread.run(Unknown Source)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-21 16:24:28

padding属性不是Label中JavaFX 2.2中的有效属性。在JavaFX 8中,Label继承了Region (通过Control),因此继承了padding属性。因此,我怀疑SceneBuilder正在查看JavaFX 8以确定属性。

在CSS 2.2中有一个可以从JavaFX设置的labelPadding属性,所以请使用

代码语言:javascript
复制
<Label style="-fx-font-weight: bold; -fx-label-padding: 6 0 18 6;" text="Storage Overview Home"
    VBox.vgrow="NEVER">

</Label>
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21263169

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档