我开始学习JavaFX 2.0并安装了Netbeans 7.1,java 7.02 SDK(包含JavaFX 2).一切似乎都有效,示例项目编译并运行良好.
我的问题是:代码完整不适用于FXML文件.我按ctrl + space,每次都显示"无建议".标签和属性也是如此.
有谁知道可能是什么问题?
我知道我可以使用以下内容将FXML文件加载到Parent对象中:
parent = FXMLLoader.load(getClass().getResource(fxmlFile.getAbsolutePath()));
Run Code Online (Sandbox Code Playgroud)
现在我想要完全相反,并将Parent对象保存为FXML文件的根目录.
有谁知道如何做到这一点?
我改进了我以前的TextField验证实现,这次使用绑定进行实时验证的真正自定义控件.它可以与FXML一起使用而无需更多的Java代码.
import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.ReadOnlyIntegerProperty;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.TextField;
import javafx.scene.effect.BlurType;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.Effect;
import javafx.scene.paint.Color;
/**
* <p>
* TextField with regex-based real-time input validation.
* JavaFX 2 and FXML compatible. </p>
* <p>
* FXML code example:<div>
* {@code <ValidatedTextField fx:id="validatedTextField" minLength="1" maxLength="1" mask="^[0-9]*$" />}
* </div>
* </p>
*
* @author 82300009
*/
public final class ValidatedTextField extends …Run Code Online (Sandbox Code Playgroud) 我想知道,是否可以<fx:constant>在属性中使用而不是单独的标签?
目前这对我有用:
<Label>
<text>
<MyController fx:constant="MY_CONSTANT_STRING" />
</text>
</Label>
Run Code Online (Sandbox Code Playgroud)
虽然我更喜欢这样的东西:
<Label text="<MyController fx:constant="MY_CONSTANT_STRING" />" />
Run Code Online (Sandbox Code Playgroud)
有可能是后者可能吗?
谢谢你的提示!
TableViewJavaFX 2.2 的类有一个泛型类型S,我想知道如何从FXML设置它?
I was working on a stage when I noticed I practically had the exact same thing three times. Rather than that (since I hate that), I decided to take what I had those 3 times and turn it into a custom component.
Now I know I can add it in code but I can't predict the layout behavior (two of these will be going into tabs directly, and the third will be going into a grid pane).
I tried importing …
我知道以下问题有点奢侈问题:
我想保持我的FXML控制器的初始化尽可能干净,因此我想在FXML文件中设置我的TableView的占位符(因为我认为这是保留它的最佳位置,因为它只是一个财产,在我的情况下也是一个常数).我已经尝试在FXML文件中设置它,如下所示:
<TableView placeholder="Some text">
Run Code Online (Sandbox Code Playgroud)
这显然不起作用,因为占位符属性需要一个Node.这就是为什么我在FXML控制器的初始化中设置这样的占位符:
Label placeholder = new Label();
placeholder.setText("Some text");
tableview.setPlaceholder(placeholder);
Run Code Online (Sandbox Code Playgroud)
这是有效的,但正如我所说,我只想从FXML文件中管理它.我的一些问题是:
如何在FXML文件中设置占位符?
注意:如果我有可能请告诉我,因为如果不是,我会填写功能请求(当然优先级低!).
我有一个问题让我疯了几天.
我有一个GridPane,我想在单击按钮时隐藏第一行.
这是FXML文件
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button fx:id="buttonTest" mnemonicParsing="false" onAction="#handleButtonTestAction" text="Button" />
<GridPane fx:id="gridPaneTest" gridLinesVisible="true" layoutX="0.5" layoutY="0.5" BorderPane.alignment="CENTER">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label fx:id="labelTopLeft" text="top left">
<font>
<Font size="15.0" />
</font>
</Label>
<Label fx:id="labelTopRight" text="top right" GridPane.columnIndex="1">
<font>
<Font size="15.0" />
</font>
</Label>
<Label text="center left" GridPane.rowIndex="1">
<font>
<Font size="15.0" />
</font>
</Label> …Run Code Online (Sandbox Code Playgroud)您好JavaFX样式表专家,
如何删除JavaFX menuButton上的默认箭头.
我已经想过如何改变颜色并使其变得不可见
.menu-button {
-fx-mark-color: transparent;
}
Run Code Online (Sandbox Code Playgroud)
要么
.menu-button .arrow {
-fx-background-color: transparent;
}
Run Code Online (Sandbox Code Playgroud)
但是,由于不可见的箭头,我不想要这个差距.
谢谢你的建议.
最好的祝福,
伊万
是否可以在FXML中设置ColorPicker的默认颜色,还是必须在FXML控制器的initialize方法中设置颜色?
fxml ×10
javafx-2 ×6
javafx ×4
java ×3
tableview ×2
autocomplete ×1
constants ×1
generics ×1
javafx-8 ×1
javafx-css ×1
netbeans-7 ×1
scenebuilder ×1
textfield ×1
validation ×1