TableCell JavaFX中的ArrayList

时间:2017-05-18 21:09:33

标签: java arraylist javafx tableview

我想用JavaFX完成类似的事情。 物品可以有一个或多个尺寸(带有相应的库存),尺寸可以存在于零个或多个物品中。

syncHistoryWithStore

我有文章课

public class Article {
    private IntegerProperty id;
    private StringProperty code;
    private StringProperty name;
    private StringProperty description;
    private ObservableList<Category> categories;
    private ObservableList<ArticleStockInfo> stockInfo;
    private Brand brand;
    private FloatProperty price;
    private BooleanProperty checked;

    //Constructor, methods
    ...
}

我也有ArticleStockInfo

public class ArticleStockInfo {
    private Size size;
    private IntegerProperty stock;

    //Constructor, methods
    ...
}

现在我在TableView中显示带有一些TableColumns的文章

@FXML private TableView<Article> articlesTable;
@FXML private TableColumn<Article, Number> articlesTableIdColumn;
@FXML private TableColumn<Article, Number> articlesTablePriceColumn;

这就是我填写表格的方式

articles = FXCollections.observableArrayList(ArticlesMethods.getAllArticles());
filteredArticle = new FilteredList<>(articles, p -> true);
SortedList<Article> sortedData = new SortedList<>(filteredArticle); sortedData.comparatorProperty().bind(articlesTable.comparatorProperty());
//Add sortedItems to the TableView
articlesTable.setItems(sortedData);

0 个答案:

没有答案