SimpleStringProperty和StringProperty之间的区别 [英] Difference between SimpleStringProperty and StringProperty
问题描述
我正在使用JavaFx TableView,发现有一些类使用TableView,例如SimpleStringProperty,StringProperty,SimpleBooleanProperty和BooleanProperty等。现在我想知道哪个用于TableView的SimpleStringProperty或者只有StringProperty和什么是它们之间的区别。
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.
推荐答案
StringProperty是可观察字符串属性的抽象基类,SimpleStringProperty是一个具体的实现。
StringProperty is the abstract base class for observable string properties, SimpleStringProperty is a concrete implementation.
规则是:
- 在API中显示StringProperty
- 使用SimpleStringProperty作为代码中的具体实现
您有时会看到JavaFX代码本身从StringPropertyBase创建匿名内部类,并且这样做的原因是它在记忆方面更有效,但你通常不必打扰自己。
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.
这篇关于SimpleStringProperty和StringProperty之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!