Is it possible to use painter or some other technique to customize text drawing on controls with synth?
I know you can implement paintButtonBorder
and paintButtonBacground
in SynthPainter, but I was wondering is there a way to do it with text? Maybe some workaround?
Typically you would create a SynthGraphicsUtils
subclass, override paintText(SynthContext ss, Graphics g, String text, Icon icon, int hAlign, int vAlign, int hTextPosition, int vTextPosition, int iconTextGap, int mnemonicIndex, int textOffset)
and return an instance of your subclass from your button SynthStyle
's getGraphicsUtils(SynthContext context)
method.
Anyway, if you are going to delegate painting to the super implementation, be wary of certain details if text
is in HTML (begins with the <html>
tag):
ss.getComponent().getText()
instead of text
.ss.getComponent().getForeground()
. For styled text, this will match the color specified in HTML/CSS.