PropertyValueFactory javafx
来源:互联网 发布:齐鲁期货软件 编辑:程序博客网 时间:2024/05/22 05:13
public class PropertyValueFactory<S,T>
extends java.lang.Object
In this example, the "firstName" string is used as a reference to an assumed firstNameProperty() method in the Person class type (which is the class type of the TableView items list). Additionally, this method must return a Property instance. If a method meeting these requirements is found, then the TableCell is populated with this ObservableValue. In addition, the TableView will automatically add an observer to the returned value, such that any changes fired will be observed by the TableView, resulting in the cell immediately updating.
If no method matching this pattern exists, there is fall-through support for attempting to call get<property>() or is<property>() (that is, getFirstName() or isFirstName() in the example above). If a method matching this pattern exists, the value returned from this method is wrapped in a ReadOnlyObjectWrapper and returned to the TableCell. However, in this situation, this means that the TableCell will not be able to observe the ObservableValue for changes (as is the case in the first approach above).
For reference (and as noted in the TableColumn cell value factory documentation), the long form of the code above would be the following:
See Also:
TableColumn, TableView, TableCell, MapValueFactory
extends java.lang.Object
implements Callback<TableColumn.CellDataFeatures<S,T>,ObservableValue<T>>
TableColumn<Person,String> firstNameCol = new TableColumn<Person,String>("First Name"); firstNameCol.setCellValueFactory(new PropertyValueFactory<Person,String>("firstName"));
In this example, the "firstName" string is used as a reference to an assumed firstNameProperty() method in the Person class type (which is the class type of the TableView items list). Additionally, this method must return a Property instance. If a method meeting these requirements is found, then the TableCell is populated with this ObservableValue. In addition, the TableView will automatically add an observer to the returned value, such that any changes fired will be observed by the TableView, resulting in the cell immediately updating.
If no method matching this pattern exists, there is fall-through support for attempting to call get<property>() or is<property>() (that is, getFirstName() or isFirstName() in the example above). If a method matching this pattern exists, the value returned from this method is wrapped in a ReadOnlyObjectWrapper and returned to the TableCell. However, in this situation, this means that the TableCell will not be able to observe the ObservableValue for changes (as is the case in the first approach above).
For reference (and as noted in the TableColumn cell value factory documentation), the long form of the code above would be the following:
TableColumn<Person,String> firstNameCol = new TableColumn<Person,String>("First Name"); firstNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<Person, String> p) { // p.getValue() returns the Person instance for a particular TableView row return p.getValue().firstNameProperty(); } }); }
See Also:
TableColumn, TableView, TableCell, MapValueFactory
- PropertyValueFactory javafx
- JavaFx
- JavaFX
- JavaFX
- javaFX
- JavaFx
- JAVAFX
- javafx
- JavaFX
- JavaFX
- javaFX
- javaFX
- JavaFX
- JavaFX
- 什么是JavaFX - JavaFX 入门
- javaFx帮助
- javaFx简介
- javaFx简介
- dp+四边形不等式优化(poj1160 hdu2829 3480 3506 3516)
- K8 SEO全能营销及时更新/定时采集让你的网站总能跟上最新资讯
- 国内最火的五款HTML5前端开发框架
- 怎样高效学习嵌入式
- PermGen space错误解决方法
- PropertyValueFactory javafx
- 学好ARM开发的意义
- 学习笔记04—HashCode相关
- 八、Oracle数据库之学习笔记---Oracle的表的基本查询(5)
- Linux 下 mysql 数据库结构目录
- NYOJ - 回文字符串(DP)
- C primer plus第14章(结构和其他数据形式)(练习)
- linux 网络社区
- jQuery easyUI动态获取表结构并显示表中的数据)