Class Key.Global
java.lang.Object
dev.pfaff.altargui.Key.Global
- All Implemented Interfaces:
Key.CallSite
- Enclosing class:
Key
Global keys, represented by
Key.Global
, like all CallSite
s, are compared by identity. Unlike
regular CallSite
s, however, they allow keyed widgets to be moved freely around the tree while
maintaining their state.
To create a global key, you must call Key.globalKey()
. The interface is sealed to prevent misuse. Be sure
to store the returned key somewhere, like in the field of a WidgetInstance
, rather than creating it on
every getState
, lest the widget be completely
recreated every time.
When the widget is truly unique in the tree, like a singleton, storing a regular CallSite
in a
static final
field would have the same effect. However, this approach makes the developer's intentions less
clear, and as such is not recommended. Additionally, code using this approach would suddenly break if the widget
were ever changed to no longer be a singleton.
-
Method Details
-
__
public void __()- Specified by:
__
in interfaceKey.CallSite
-