Ste*_*bbi 8 java javafx intellij-idea scenebuilder
我有一个自定义JavaFx控件,在我的应用程序中呈现.但是,我不能让SceneBuilder理解它.
我有CustomTextField.java/CustomTextField.fxml.CustomTextField从用户控件继承,定义在这里,但是我创造的任何自定义控制我的场景生成器的问题发生.
首先,我必须将我的import语句更改为通配符.从
<import sample.CustomTextField>
Run Code Online (Sandbox Code Playgroud)
至
<import sample.*>
Run Code Online (Sandbox Code Playgroud)
否则,scenebuilder抛出一个异常/显示一个栈跟踪,表明无法找到源文件.我不知道为什么这是必要的,但似乎有效,所以我继续前进.
我已经读过你要在fxml文件中指定一个scenebuilder-classpath-element.所以,我尝试了我能想到的每一个组合:
<?scenebuilder-classpath-element ../../bin?>
<?scenebuilder-classpath-element ../../out?>
<?scenebuilder-classpath-element ../../../out?>
<?scenebuilder-classpath-element ./?>
<?scenebuilder-classpath-element ../../../../../target/classes?>
Run Code Online (Sandbox Code Playgroud)
我的问题是自定义控件不会在Scene Builder中呈现.在层次结构树中选择它,它表示"选择包含未解析的引用".如果我无法拖放自定义控件,那是可以接受的.但是,我真的想在Scene Builder中渲染它并布置其他东西.
我正在使用IntelliJ IDEA 14和Scene Builder 2.0
sample.fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import sample.*?>
<?scenebuilder-classpath-element ../../bin?>
<?scenebuilder-classpath-element ../../out?>
<?scenebuilder-classpath-element ../../../out?>
<?scenebuilder-classpath-element ./?>
<?scenebuilder-classpath-element ../../../../../target/classes?>
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Button fx:id="topButton" layoutY="2.0" mnemonicParsing="false" text="Button Top" />
<CustomTextField fx:id="myCustomTextField" layoutX="1.0" layoutY="40.0" />
<Button layoutX="1.0" layoutY="125.0" mnemonicParsing="false" text="Button Bot" />
</children>
</Pane>
Run Code Online (Sandbox Code Playgroud)
小智 0
我能够加载自定义类。我们通过使用自定义类构建 .jar 来使其工作,然后在 SceneBuilder 中,转到搜索库旁边的设置图标并导入自定义库。然后找到你的.jar。也许你可以对 .class 文件做同样的事情?
这是 .fxml 中的导入语句:
<?import com.rlsciences.autoredact.view.ItemsTableView?>
Run Code Online (Sandbox Code Playgroud)
这是我在 .fxml 中使用它的地方:
<ItemsTableView id="searchResultsTableView" fx:id="searchResultsTableView" fixedCellSize="20.0" styleClass="compact-table" VBox.vgrow="ALWAYS">
Run Code Online (Sandbox Code Playgroud)
这是类定义:
package com.rlsciences.autoredact.view;
public class ItemsTableView<S> extends TableView<S>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1448 次 |
| 最近记录: |