observablelist

How to bind the position in a List to an attribute of that element?

给你一囗甜甜゛ 提交于 2019-12-14 01:45:40
问题 I have an ObservableList<MyElement> list = FXCollections.observableArrayList(); public class MyElement { private IntegerProperty position;//with getter //[...] //somewhere in the constructor taking the list as argument position.bind(list.indexOf(this)); } Now I'd like to bind MyElement.position to the actual position in the list i.e. if the position changes in the list (for instance drag and drop in the GUI or anything else) I want the position property to be updated automatically. Is this

How to concatenate observable lists in JavaFX?

女生的网名这么多〃 提交于 2019-12-13 13:26:54
问题 By concatenation I mean obtaining a new list, which listens for changes in all concatenated parts. What is the purpose of method FXCollections#concat(ObservableList<E>... lists)? If it just merges several lists, then I see no sense to have separate method for this. And if regard as doing what I wish then it doesn't work: import javafx.collections.FXCollections; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; public class ConcatObservabeList { public

how to pass data from parsed text file and insert the values to ObservableList in javafx?

戏子无情 提交于 2019-12-13 08:08:21
问题 content of text file gr.spinellis.ckjm.ClassVisitor 13 2 0 14 74 34 2 9 gr.spinellis.ckjm.ClassMetricsContainer 3 1 0 3 18 0 2 2 gr.spinellis.ckjm.MetricsFilter 7 1 0 6 30 11 2 5 gr.spinellis.ckjm.PrintPlainResults 2 1 0 2 8 0 1 2 gr.spinellis.ckjm.MethodVisitor 11 2 0 21 40 0 1 8 gr.spinellis.ckjm.CkjmOutputHandler 1 1 0 1 1 0 3 1 i am parsing text file and then i want to view the values in organized way , the parsing works well , now i want to put the values i get from text file to

JavaFX - Using a ChangeListener on a ComboBox to populate another ComboBox with an ArrayList results in the ArrayList being empty

两盒软妹~` 提交于 2019-12-13 03:07:01
问题 I posted this question two days ago about attaching a ChangeListener to a ComboBox to dictate what output would be shown on a second ComboBox. To put this in short, the idea was that the first ComboBox shows some Unit Types, and depending on the Unit Type chosen would depend on the list of Units shown in the second ComboBox based on the Unit Type chosen. For example If you chose the "Elites" Unit Type in the first ComboBox the second ComboBox should be populated with all the "Elite" units.

Javafx tableview items prevent duplicates

六眼飞鱼酱① 提交于 2019-12-12 18:30:09
问题 I'm using javafx tableview with observableList list, I tried to prevent list from holding duplicate items. After doing some search, i figure out that an observableSet can do this job by overidding thoes methodes:equals() and hashcode(). But the problem that javaFX tableview can't hold an observable set: tableView.setItems(FXCollections.observableSet(new hashSet<T>()); I also planned to calculate the some for a columns in my tableview so, i need // After change in element T the total will

How to know from ListChangeListener.Change about which elements were removed?

被刻印的时光 ゝ 提交于 2019-12-11 14:26:01
问题 ObservableList is ordered by nature and most access and reportings are index-based. But suddenly, when reporting about removements, they switched to value-based approach. Why? I have second list, which is carrying additional information for ObservableList and want to keep it in sync with ObservableList. I can track permutations, updatings and additions, but I can't track removements. Why? How to know the indices of removed elements from ObservableList? Is it possible? JavaFX 8 doc is here:

no error then why ObservableList is not working in this project?

蓝咒 提交于 2019-12-11 12:39:41
问题 i saw this project in previous answer and I tried to run it but it didn't how to pass data from parsed text file and insert the values to ObservableList in javafx? data inputted from text file to table view and then piechart JAVAFX, everything was work except the pie chart I am trying to get data from table view to pie chart, i have done after few edits I can't run it anymore the problem in ObservableList pieChartData = FXCollections .observableArrayList() this is the code package show;

JavaFx 2 ChoiceBox with custom item

狂风中的少年 提交于 2019-12-11 10:44:31
问题 I have a class such as: public class myClass{ int age; String name; public String toString(){ return name; }; } public static ObservableList<myClass> myClassList; I wonder if is it possible to have ChoiceBox<myClass> choiceChart = new ChoiceBox<>(myClassList); Thanks PS I would like to have a similar situation as Rendering a POJO with JavaFX 2 but using a ChoiceBox Edit: this is my situation: I have a tableView where in one of its columns I have to set a String from an object of myClass type,

JavaFX ObservableList remove element in listener throws exception

旧时模样 提交于 2019-12-11 07:23:57
问题 When I attach listener to observable list and in that listener I try to remove some element, in some cases it passes and in some cases it crashes. Scenario: Item is removed from a list. It triggers listener, and in that listener I try to delete another item. If in listener I try to remove element that is not just next to initially removed, it works OK. If in listener I try to remove element that is JUST NEXT to initially removed, it crashes with UnsupportedOperationException!!! Did anybody

JavaFX bidirectional binding of two different, non-String, ListProperty

天大地大妈咪最大 提交于 2019-12-11 05:17:27
问题 I need to bind together two ListProperties: ObservableList<Data<Number, Number>> chartDataList = FXCollections.observableArrayList(); ListProperty<Data<Number, Number>> chartDataProperty = new SimpleListProperty<>(this, "chartData", chartDataList); ObservableList<Point2D> observableData = FXCollections.observableArrayList(); ListProperty<Point2D> dataProperty = new SimpleListProperty<>(this, "Data", observableData); chartDataList will be used to display a LineChart, while the other ( data )