有没有一种简单的方法可以使用JavaFX创建多个TextField?

时间:2019-06-08 01:01:07

标签: java javafx textfield

我正在尝试创建大约十二个TextField,并且想知道是否存在一种快速简便的方法。

const cars = [
  { model: "convertible", year: "2015", use: "sports" },
  { model: "wagon", year: "2013", use: "family" }
];

const buyers = [
  { name: "John", searchingUse: "family", maxYear: "2014", maxPrice: "15000" },
  { name: "Mark", searchingUse: "ddd", maxYear: "2012", maxPrice: "1000" }
];

const a = buyers
  .map(buyer => ({
    [buyer.name]: cars.filter(car => car.use === buyer.searchingUse)
  }));

console.log(a);

我觉得有一种我不知道的更有效的方法

1 个答案:

答案 0 :(得分:4)

您可以使用简单的for循环将新的TextField添加到List

List<TextField> timeTextFields = new ArrayList<>();
for (int i = 0; i < 5; i++) {
    timeTextFields.add(new TextField("Time #" + i));
}