如果这是重复的,我很抱歉,但我还没有找到答案。
我正在开发一个在 JavaFX 中运行基本库存管理系统的项目。我目前正在尝试允许用户将新项目添加到 SQLite 数据库中,虽然 ID 和项目名称被添加到数据库中就好了,但输入到文本字段中的初始值似乎被忽略了。
程序将值 0.0 放在可用单位字段中。这是我当前的代码:
Main.java
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage){
try {
Parent root = FXMLLoader.load(getClass().getResource("DatabaseView.fxml"));
Scene scene = new Scene(root);
primaryStage.setTitle("Brewer's Guide Inventory Management");
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
beerDatabaseData.java
package sample;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
public class beerDatabaseData {
private final StringProperty ID;
private final StringProperty name;
private DoubleProperty units;
public beerDatabaseData (String ID, String Name, Double Units)
{
this.ID = new SimpleStringProperty(ID);
this.name = new SimpleStringProperty(Name);
this.units = new SimpleDoubleProperty(Units);
}
public StringProperty IDProperty()
{
return this.ID;
}
public String getID()
{
return this.IDProperty().get();
}
我想有一个明显的问题导致了这种情况,但我没有看到它。我需要更改或包含哪些内容才能使这项工作有效?提前谢谢你。
陪伴而非守候
相关分类