• Post Reply Bookmark Topic Watch Topic
  • New Topic

LinearGradientPaint looks different drawn to JComponent vs BufferedImage (pic example inside)?  RSS feed

 
Nathan deNoyelles
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone!

I've run into a curious problem, I bet its just something i'm looking over. Here's the problem, I'm using a LinearGradientPaint with two opaque colors and the very last color completely transparent.

Painting to a JPanel the drawing seems to ignore the transparent color at the end and fades to nothing with the second to last color:


However painted to a BufferedImage with the exact same code, the gradient changes to blue as it fades to nothing which I would expect:


See the difference? What could be causing this, my goal is to have the gradient look the same on the JComponent as it does on the BufferedImage.

Here's a short example that's easy to compile if you want to give it a try. To toggle between the BufferedImage and the JComponent just click anywhere in the window. Thank you for your help


 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!