i paint half of the label with one graphics2d and the other half with an other graphics2d
You do?
And you need to dispose()
all Graphics objects that you create.
The code looks horribly convoluted, with multiple and chained calls to
Color#darker() /
brighter() at every repaint. Those colors should be cached, and if there is a possibility of the background being changed during the run of the program, register a
PropertyChangeListener for the "
background" property and renew the cache when that changes. The
Paints could also be cached and renewed via a
ComponentListener's
componentResized(...)
Finally, I don't see any rendering that couldn't be done with a
single LinearGradientPaint instead of two
GradientPaints.
edit: Forgot to add, that a custom appearance
should be managed by a custom UI delegate -- a LabelUI extending BasicLabelUI or (for massive customization) LabelUI -- not by extending the component class.