我有一些非常菜鸟的问题。我尝试在 OpenJDK 14 中使用 jpackage 为我的测试应用程序创建安装。这是我所做的:
首先,创建自定义 JRE
jlink --module-path "C:\Java\javafx-sdk-14\lib" --add-modules javafx.controls,javafx.fxml --output hello\myjre
Run Code Online (Sandbox Code Playgroud)
那是成功的。我从运行配置中从我的 Eclipse 中复制了参数。之后使用 jpackage 进行安装
jpackage --name HelloFX --input hello --main-jar HelloFX.jar --runtime-image hello\myjre
Run Code Online (Sandbox Code Playgroud)
创建了 .msi 文件,我运行它并在我的 Win10 应用程序中创建了条目。当然,我不知道如何在 windows 菜单中找到它,但它放在我的 C:\Program Files\HelloFX 中。我找到了带有 Duke 图像的图标和应用程序文件,当我尝试运行应用程序时,会弹出“无法启动 JVM”消息。
有人可以帮助我,我做错了什么?我真的很想完成这项工作并深入研究 JavaFX。
我有 1 个类文件 Nepokretnost.java,其中的构造函数如下所示:
public Nepokretnost(String tipNepokretnosti, String zona, String pravo,
double povrsina, int amortizacija, double osnovica, double kredit, double porez) {
this.tipNepokretnosti = tipNepokretnosti;
this.zona = zona;
this.pravo = pravo;
this.povrsina = povrsina;
this.amortizacija = amortizacija;
this.osnovica = osnovica;
this.kredit = kredit;
this.porez = porez;
}
Run Code Online (Sandbox Code Playgroud)
此外,对于每个类字段,我都有带有列的 TableView。我的问题是双场“povrsina”。我想从 TextField 设置它。
我将名为 txtPovrsina 的 TextField 内容发送到双变量:
double dPovrsina;
dPovrsina = Double.parseDouble(txtPovrsina.getText());
Run Code Online (Sandbox Code Playgroud)
然后将所有字段放在 TableView 中:
ObservableList<Nepokretnost> data = tblTabela.getItems();
data.add(new Nepokretnost(cboNepokretnost.getValue().toString(),cboZona.getValue().toString(),
txtPravo,dPovrsina,40,450000.25,2500.00,2500.00));
Run Code Online (Sandbox Code Playgroud)
一切正常,但我想要一些应用程序的行为,我不知道如何设置。现在,当我将像 25 这样的 int 放入 TextField 时,我在 TableView 列中得到 …
诺布需要再次帮助.:)
我有一个名为tblTabela的TableView和一个名为btnIzracunaj的Button.我需要的是将Button禁用属性与TableView绑定,以便在TableView没有内容时禁用Button.
当TextFields为空时,我做了与另一个Button类似的绑定,如下所示:如何在TextField为空时禁用Button?
BooleanBinding bb = new BooleanBinding() {
{
super.bind(txtPovrsina.textProperty(),
txtPrvi.textProperty(),
txtDrugi.textProperty());
}
@Override
protected boolean computeValue() {
return (txtPovrsina.getText().isEmpty()
|| txtPrvi.getText().isEmpty()
|| txtDrugi.getText().isEmpty());
}
};
btnDodaj.disableProperty().bind(bb);
Run Code Online (Sandbox Code Playgroud)
但我的问题是使用TableView,我不知道如何设置绑定属性.应该使用TableView的哪些属性?我试过这个,它没有返回错误,但也没有按预期工作.我相信getItems()应该有别的东西,但无法弄清楚是什么.:(
BooleanBinding ee = new BooleanBinding() {
{
super.bind(tblTabela.getItems());
}
@Override
protected boolean computeValue() {
return (tblTabela.getItems().isEmpty());
}
};
btnIzracunaj.disableProperty().bind(ee);
Run Code Online (Sandbox Code Playgroud)
提前致谢.