A distinct rendering area of a Swing component. A component may
support one or more regions. Specific component regions are defined
by the typesafe enumeration in this class.
Regions are typically used as a way to identify the Component
s
and areas a particular style is to apply to. Synth's file format allows you
to bind styles based on the name of a Region
.
The name is derived from the field name of the constant:
- Map all characters to lowercase.
- Map the first character to uppercase.
- Map the first character after underscores to uppercase.
- Remove all underscores.
For example, to identify the
SPLIT_PANE
Region
you would use
SplitPane
.
The following shows a custom
SynthStyleFactory
that returns a specific style for split panes:
public SynthStyle getStyle(JComponent c, Region id) {
if (id == Region.SPLIT_PANE) {
return splitPaneStyle;
}
...
}
The following
xml
accomplishes the same thing:
<style id="splitPaneStyle">
...
</style>
<bind style="splitPaneStyle" type="region" key="SplitPane"/>