问题标签 [observablelist]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - 如何将列表中的位置绑定到该元素的属性?
我有一个ObservableList<MyElement> list = FXCollections.observableArrayList();
现在我想将 MyElement.position 绑定到列表中的实际位置,即如果列表中的位置发生变化(例如在 GUI 中拖放或其他任何东西),我希望位置属性能够自动更新。
这可能吗?我可以在这些值之间进行双向绑定吗?
javafx - 作为参数传递给数据模型的计算值未显示在 tableview 上
我有一个包含 4 个 TextField 的表单,我试图用一个包含 5 列的 ObservableList 来跟踪它。TableView 有一个额外的列来保存计算值(我的 ObservableList 中的第 5 列)。
数据从 4 个文本字段中很好地转储,但计算的列显示为空白。我认为这是我的 getter 和 setter 的问题,因为值是在我将其传递给我的数据模型之前计算的,并且我刚刚测试了数据模型,它正在获取值(作为参数传递)。
为了不在这里放置无关代码,我认为这些是相关部分:
// 这是我的数据模型的(部分)
// price * quantity = rowPrice,计算后不显示的值
// 数量的获取器和设置器(有效,是我表单中的文本字段)
// rowPrice 的 getter & setter(不起作用,是计算出来的,见下文)
// 在添加按钮操作处理程序中,我有这个:
javafx-2 - 从 observablelist 插入/更新 SQL 表
好的,所以我正在使用 ObservableList,它工作正常,但现在我需要使用 observable 列表将行插入和更新 SQL 数据库表中的行。我发现很少有关于在 JavaFX 和 SQL 数据库之间工作的信息……数据表的所有示例都有在 java 代码中创建的数据。当我在这篇文章中看到“更新 SQL 数据库”时,我充满了希望:
从 Glassfish 服务器上的 FoxPro 数据更新 sql 数据库
但不适用于我的情况。
所以问题是,如何启动从 ObservableList 中读取的代码,以便运行我的 SQL Insert 语句?如果您能指出一个使用 ObservableList 并创建/添加/更新 SQL 表的示例代码,我将不胜感激。
谢谢!
更新问题:
我不能在这里发布相关代码,因为相关部分是我没有的。但是,我在想我需要做的是这样的事情:
显然,我正在将我对其他领域的知识应用到 ObservableList,但我这样做是为了展示我不知道如何处理我的 ObservableList(mylist)。
再次感谢您的帮助。
java - javaFX:如何创建 Live ListView 并向其添加 ChangeListener
我编写了一个 JavaFX 用户界面 (fxml) 并将一个控制器类绑定到它,一切正常,直到我在我的应用程序中为 ListView 添加了一个 ObservableList 和一个 ChangeListener。当我运行应用程序时,ListView 看起来不错并显示正确的值,但是当我单击某些按钮时,会发生异常并且按钮将不起作用。这些按钮应该在单击时显示其他布局。异常表示未找到布局(例如 AddUser.fxml),但它存在并正常工作到现在!
控制器类的一些行:
用户类(模型):
当我单击“添加”按钮时,调用了 showAddUserLayout() 并出现以下异常:
请帮忙!我不知道发生了什么...提前谢谢!
java - Platform.runLater
我有一个连接到套接字连接的应用程序,并且该连接向我发送了很多信息.. 可以说每秒 300 个订单(可能更多).. 我有一个类(它就像一个监听器,对某些事件和该事件具有订单)接收该订单..创建一个对象,然后将其添加到一个 ObservableList (这是一个 tableView 的来源).. 这样我的 GUI 显示该订单。但是问题来了,如果 observableList 上已经存在该订单..我无法添加它..我必须更新它(我这样做)..但有时..对于某些订单,这种情况不起作用并再次添加订单。
我将向您展示它是如何与一些代码一起工作的。
现在好了..这是我的代码的简历。ev 是我的事件,包含订单的所有信息,orderID 是我用来查看订单是否已经存在的键(并且是唯一的)。“Repository”是一个单例类,“ordersCollection”是一个 ObservableList,“ordersIdMap”是一个 HashMap
filter - ListChangeListener,JavaFX
我有一个与 ObservableList 上的过滤器有关的问题。我的代码工作正常,但我认为太慢了。这是因为我在应用程序开始时加载了大约 40,000 个订单,之后应用程序继续接收订单,但现在我只在初始加载时遇到问题。我的主要问题是我的原始订单集合的副本要慢得多,为什么?因为我在changeListener中的代码我认为可能会更好..但我还没有找到解决方案。好吧,这是我的代码示例。
我会稍微解释一下代码。“存储库”是一个单例,masterObservableList 是一个 ObservableList,顾名思义..是“主”或原始。filtersData 也是一个 ObservableList,但仅在我的 fxml (MainController) 的控制器中声明,并作为主集合的副本。每次我的主集合收到更改(更新或新订单)时,filteredData 都应该应用该更改..但是我为每次迭代都做一个,这是问题,因为它有效但太慢了。为什么我说这很慢?因为一开始我使用主集合作为显示订单的 TableView 的数据提供者,它工作得又快又干净。之后我想向表中添加过滤器,这就是我开始进行研究并发现过滤后的数据和另一种方法的时候..我保留了这个方法(是一个更大的代码,但主要问题在这里)..它工作.. 但是一开始加载订单的时间比以前多 1:30 分钟.. 所以伙计们,如果你有任何想法!关于如何在不为 changeListener 中的每个内容创建的情况下保持过滤数据的更新,我将非常高兴和感激。谢谢阅读!
java - 将所有内容添加到 baund observablelist 后,Jtable 未显示数据
我在一个名为 EntradaMercadoriaList 的可观察对象列表上的 jtable 上遇到了一些困难。添加此列表中的所有对象后,jtable 仅显示与列表大小等效的空行
这是我的代码:
这是我的 EntadaMercadoria 对象:
怎么了?有没有办法刷新表格以显示行中的数据?
谢谢。
java - 初始化对象属性>?
我有一个包含ObservableList
. 但我不知道如何初始化它。目前我正在这样做
这显然是完全不好的做法。另一个是
但这需要以后注意,我尽量避免用空列表初始化内部 ObservableList。
我搜索这样的东西
dart - Dart Polymer - 通过构造函数传递数据
I have a ObservableList that will be holding a bunch of Elements. As I add() to the ObservableList I use a <template repeat>
to show the element.
When I make the e
I have a ObservableList that will be holding a bunch of Elements. As I add() to the ObservableList I use a <template repeat>
to show the element.
When I make the element I would like to pass some data (in this case a VO) straight into the Constructor of the new element, then I run the add() on ObservableList. Everything seems to work the way I want until I add(), then I get an error "Exception: No constructor 'MyAlert.' declared in class 'MyAlert'." - where MyAlert is the class name (this constructor definitely exists).
I can print out the VO within the new element, but as soon as it is added to the I get issues. Can this just not be done and I'll have to pass the data I need via the HTML template?
Thanks,
Robbie
How to turn an number into a roman numeral?
For a class we are creating a program that takes in a number and spits it out as a roman numeral. This should be really simple, because we don't even have to worry about four being IV. In this program four would be IIII. Anyone have any suggestions on how to do this...? We can't use array's. His instructions state:
This method prints, to the standard output and in purely additive
* notation, the Roman numeral corresponding to a natural number.
* If the input value is 0, nothing is printed.
I've tried it a couple different ways, and my logic just isn't right. I would really appreciate any suggestions you may have.
Here is what I last tried...
0
投票
2
回答
2077
浏览
c# - 从 ObservableCollection 中删除名称出现在其他列表中的项目
我有ObservableCollection a
和List b
现在我想从a
在 list 中具有等价物的集合元素中删除b
。
我此时的代码:
用法:
此代码从集合中删除“2”、“3”和“5”,留下“1”、“4”、“6”和“k”。
在我的真实代码中a
并b
包含从相同继承的元素,interface
我正在比较该接口中的属性,但我无法利用它。
我无法创建新列表,因为它绑定到 wpf 视图,如果我这样做而不是删除项目,将会出现明显的故障。
有没有更好/更快的方法来做到这一点?
I have a ObservableList that will be holding a bunch of Elements. As I add() to the ObservableList I use a <template repeat>
to show the element.
When I make the e
I have a ObservableList that will be holding a bunch of Elements. As I add() to the ObservableList I use a <template repeat>
to show the element.
When I make the element I would like to pass some data (in this case a VO) straight into the Constructor of the new element, then I run the add() on ObservableList. Everything seems to work the way I want until I add(), then I get an error "Exception: No constructor 'MyAlert.' declared in class 'MyAlert'." - where MyAlert is the class name (this constructor definitely exists).
I can print out the VO within the new element, but as soon as it is added to the I get issues. Can this just not be done and I'll have to pass the data I need via the HTML template?
Thanks,
Robbie
How to turn an number into a roman numeral?
For a class we are creating a program that takes in a number and spits it out as a roman numeral. This should be really simple, because we don't even have to worry about four being IV. In this program four would be IIII. Anyone have any suggestions on how to do this...? We can't use array's. His instructions state:
This method prints, to the standard output and in purely additive * notation, the Roman numeral corresponding to a natural number. * If the input value is 0, nothing is printed.
I've tried it a couple different ways, and my logic just isn't right. I would really appreciate any suggestions you may have.
Here is what I last tried...
c# - 从 ObservableCollection 中删除名称出现在其他列表中的项目
我有ObservableCollection a
和List b
现在我想从a
在 list 中具有等价物的集合元素中删除b
。
我此时的代码:
用法:
此代码从集合中删除“2”、“3”和“5”,留下“1”、“4”、“6”和“k”。
在我的真实代码中a
并b
包含从相同继承的元素,interface
我正在比较该接口中的属性,但我无法利用它。
我无法创建新列表,因为它绑定到 wpf 视图,如果我这样做而不是删除项目,将会出现明显的故障。
有没有更好/更快的方法来做到这一点?