0
這是我表視圖(不FX類的我自己的數據)JavaFX的表不接受數據
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);
}
現在我的問題是我的數據沒有插入數據!因爲它在控制檯上打印的效果與我想要的一樣好!
或者根本就沒有使用'PropertyValueFactory',當然... –
lembda表達錯誤是在我使用你的方式時給出@fabian –
這裏不需要lambda表達式 –