Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swing component default gradient background

Is there a way to change the default background painting of all instances of a swing component (a JPanel for example) to paint with a gradient background? Or would I need to create an extension of JPanel that paints with a gradient and then use that instead of JPanel everywhere in my app?

like image 810
Jeff Storey Avatar asked Mar 09 '12 14:03

Jeff Storey


1 Answers

IMHO, it would be easier to just subclass the Swing component and override its paintComponent method to do the gradient painting. And then, as you said, use this custom component throughout the application.

It could be tricky using the UI properties since they may not be consistent across all LaFs.

like image 93
Moonbeam Avatar answered Oct 11 '22 23:10

Moonbeam