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:
- Show StringProperty in your API
- 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.