Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using GradientPaint and Swing Components  RSS feed

 
John Macek
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there is any way to use GradientPaint to have my swing components with a gradiated background? I want to have a Jpanel that shades from one color to another from top to bottom. I am using the JPanel in an extension of the JDialog class. I have tried overriding the paint method in my extension of JDialog and calling Graphics2D's setPaint method to use a GradientPaint. I have also tried calling the JPanel's getGraphics method and using setPaint on that. None of this has made any difference. The runtime class of each Graphics is SunGraphics2D. I have been unable to find source code for this class.
Any help would be greatly appreciated.
Thanks,
John
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's some example code I made for a JPanel that has a GradientPaint background... Hopefully this helps you out...



-Nate
 
John Macek
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's pretty much what I did. Thanks.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!