Selectors extract or select values from other objects based on a key or index. Selectors are useful in GUI applications and applets.

For example, consider an application where the user types in a name and you wish to display a phone number associated with the name. The mappings between names and numbers can be stored in a collection such as a `com.sas.collection.Dictionary`. Using property linking, you can link the `text` property of a com.sas.awt.TextField to the `key` property of a `Selector`. Then, link the `value` property of the selector to the phone number `TextField`. Finally, set the `Dictionary` as the selector's `collection` using the setCollection(Object) method. |
When the `Name:` field changes, it fires a `PropertyChangeEvent` and the selector's `key` property is updated with the new name. The selector will then select the corresponding value from the collection and fire a `PropertyChangeEvent`, which will cause the Phone: text field to update with the phone number associated with the name. By also linking the `Phone:` text field's `text` property to the selector's `value` property and linking the selector's `key` to the name `TextField`, you can also do reverse lookups: enter a phone number and the name associated with the phone number will be sent to the `Name:` field: |
You may also cascade selectors if you have more complex indexing schemes. For example, if you wish to select an item from a two dimensional array based on two indices, cascade the selectors as in the following picture. |