How to fill TableView with ObservableMaplt;KeyObject, ObservableListlt;CustomObjectgt;gt; in JavaFX(如何用 ObservableMaplt;KeyObject, ObservableListlt;CustomObjectgt;gt; 填充 TableView在 JavaFX 中)
问题描述
我的 Java 程序产生了大量数据,我用这些数据构造了单独的 ResultObject.因为只有某些 ResultsObjects 会感兴趣,所以我用我的结果填充 ObservableHashMap<>.CustomObject 由几个整数 + 双精度和一个 JSONObject 组成.有了这个CustomObject,我想将类似的ResultObjects(具有某些共同属性)映射到那个CustomObject.
My Java programm produces a lot of data, with wich I construct individual ResultObject. Because only certain ResultsObjects will be of interest, I populate an ObservableHashMap<> with my results. The CustomObject consists of a handful ints + doubles and one JSONObject. With this CustomObject I want to map similar ResultObjects(which have certain properties in common) to that one CustomObject.
虽然映射和处理这些结果按预期工作,但我几乎无法使用 ObservableHashMap<> 填充 TableView.
While mapping and handling those results works as intended, I am pretty much helpless to populate a TableView with that ObservableHashMap<>.
我的CustomObject(JSONObject只是为了检查,如果两个CustomObjects具有相同的属性):
My CustomObject (JSONObject simply to check, if two CustomObjects have the same properties):
我的 ObservableHashMap 对象:
My ObservableHashMap Object:
通过使用下面的代码,我检查是否有一个键已经存在相应的数据点,然后添加到它的 ObservableList(值):
By using the following code, I check if there is a key with the corresponding datapoints already present to then add to its ObservableList (Value):
我像这样填充其他一些 TableView:
I populate some other TableView like this:
最后我想要一些 TableColumns 来显示来自 CustomObject 的属性.稍后,我希望所选 CustomObject 的各个映射 ObservableLists 显示在单独的 TableView 中.
In the end I want some TableColumns to show properties from the CustomObject. Later on, I would want the individual mapped ObservableLists of a selected CustomObject to be shown in a seperate TableView.
我对 Java 和 JavaFX 还很陌生,我希望尽可能专业地描述我的问题.如果我遗漏了什么,请告诉我.
I am pretty new to Java and JavaFX and I hope to have described my problem as professional as possible. Please let me know, if I missed anything.
推荐答案
这应该适用于 List
Main.java
LineItem.java
这篇关于如何用 ObservableMap<KeyObject, ObservableList<CustomObject>> 填充 TableView在 JavaFX 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!