Difference between SimpleStringProperty and StringProperty

时间秒杀一切 提交于 2019-11-30 08:07:43

问题


I am working with JavaFx TableView and found there are some classes to use a TableView for example SimpleStringProperty, StringProperty, SimpleBooleanProperty and BooleanProperty, etc. Now I am wondering about which one to use for TableView either SimpleStringProperty or only StringProperty and what are the difference between them.


回答1:


StringProperty is the abstract base class for observable string properties, SimpleStringProperty is a concrete implementation.

The rule is:

  1. Show StringProperty in your API
  2. Use SimpleStringProperty as the concrete implementation in your code

You sometimes see JavaFX code itself createing anonymous inner classes from StringPropertyBase and the reason for this is that it is a bit more effecient memorywise but nothing you normally have to bother yourself.



来源:https://stackoverflow.com/questions/28060633/difference-between-simplestringproperty-and-stringproperty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!