Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1022
  • Last Modified:

BufferedImage on JButton

I'm outa points so I don't hold out much hope of anyone replying but,

I have loaded a jpg into a BufferedImage and converted to an ImageIcon and stuck it on a JButton either in the JButton constructor or using setIcon(...)

Is there an easy way to make the BufferedImage 50% transparent or change it to grayscale or anything (I want the button to gray out or faded colour.

Thanks
0
KOTOR
Asked:
KOTOR
1 Solution
 
mtcmediaCommented:
You can use AlphaComposite.

Draw a Rectangle over the button, and then keep calling repaint, each time updating the AlphaComposite value, which will allow you to paint a white rectangle and gradually make it more and more transparent, this will make it look like the button is fading in :)

This is how to do it!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now