【发布时间】:2016-12-01 23:05:17
【问题描述】:
这是我的表格视图类(不是我自己的数据类 FX)
class tableView {
SimpleIntegerProperty profit;
SimpleDoubleProperty probabilty;
public tableView(int profit, double prob) {
this.profit = new SimpleIntegerProperty(profit);
this.probabilty = new SimpleDoubleProperty(prob);
}
}
我的事件处理程序和其他控制器的代码是:
Random r = new Random();
int noOfStream = Integer.parseInt(steamsize.getText());
double sellingPrice = Double.valueOf(sell.getText());
double costPrice = Double.valueOf(cost.getText());
int quantity = Integer.valueOf(Quantity.getText());
double discountPrice = Double.valueOf(discount.getText());
int randomStart = Integer.parseInt(RandStart.getText());
int randomEnd = Integer.parseInt(RandEnd.getText());
for (int i = 0; i < noOfStream; i++) {
int dem = r.nextInt(randomEnd - randomStart) + randomStart;
int profit = profitCacl(sellingPrice, costPrice, quantity, discountPrice, dem);
double prob = cal.probCal(profitArray, profit);
// System.out.println(profit);
// System.out.println(prob);
if (prob == 0.1) {
profitArray.add(new tableView(profit, prob));
}
}
}
@Override
public void initialize(URL url, ResourceBundle rb) {
cal = new methodsForCal();
choice.setItems(FXCollections.observableArrayList(
"Normal",
"Poison",
"Uniform"
));
Profit.setCellValueFactory(new PropertyValueFactory("profit"));
Probabilty.setCellValueFactory(new PropertyValueFactory("probabilty"));
profitArray = FXCollections.observableArrayList();
tableForReading.setItems(profitArray);
}
现在我的问题是我的数据没有插入数据!因为它在控制台上打印得和我想要的一样好!
【问题讨论】: