SynthPainter
is used for painting portions of
JComponent
s. At a minimum each
JComponent
has two paint methods: one for the border and one for the background. Some
JComponent
s have more than one
Region
, and as
a consequence more paint methods.
Instances of SynthPainter
are obtained from the
SynthStyle.getPainter(javax.swing.plaf.synth.SynthContext)
method.
You typically supply a SynthPainter
by way of Synth's
file format. The following
example registers a painter for all JButton
s that will
render the image myImage.png
:
<style id="buttonStyle">
<imagePainter path="myImage.png" sourceInsets="2 2 2 2"
paintCenter="true" stretch="true"/>
<insets top="2" bottom="2" left="2" right="2"/>
</style>
<bind style="buttonStyle" type="REGION" key="button"/>
SynthPainter
is abstract in so far as it does no painting,
all the methods
are empty. While none of these methods are typed to throw an exception,
subclasses can assume that valid arguments are passed in, and if not
they can throw a NullPointerException
or
IllegalArgumentException
in response to invalid arguments.