Getting the color where you clicked the JPanel?

I only need a way to activate if the clicked pixel is white. How would I implement this? Trying to search for a method that returns a color at a coordinate, but I cannot find it.

+2


source to share


1 answer


Depends. If you have a BufferedImage (or some other image), you can use its methods getRGB

(or getRaster().getPixel

). If you haven't, you can use JPanel methods createImage

and use the returned image to get the pixel data.



+1


source







All Articles