如何从javafx组合框获取模型ID

时间:2018-08-16 16:46:26

标签: java javafx

if (validateInput()) {
    Product product = productModel.getProduct(productBox.getSelectionModel().getSelectedIndex()+1);
    Supplier supplier = supplierModel.getSupplier(supplierBox.getSelectionModel().getSelectedIndex() + 1);
    double quantity = Double.parseDouble(quantityField.getText());
    double price = Double.parseDouble(priceField.getText());
    double total = quantity * price;
    Purchase purchase = new Purchase(
            product,
            supplier,
            quantity,
            price,
            total
    );
}

这是我的代码段,productBox.getSelectionModel().getSelectedIndex()+1  在数据库中按顺序查找id = 1,2,3,4时发现工作,但是当id = 3,4的值不按顺序时它显示空积。请帮助我是javafx的新手

0 个答案:

没有答案