开发者

Getting the colour of where you have clicked on a JPanel?

开发者 https://www.devze.com 2022-12-26 18:45 出处:网络
I only want a method to activate if the pixel that is clicked is white. How woul开发者_开发问答d I implement this? Trying to look for a method that returns the colour at a coord, but I can\'t find one

I only want a method to activate if the pixel that is clicked is white. How woul开发者_开发问答d I implement this? Trying to look for a method that returns the colour at a coord, but I can't find one.


Depends. If you have got a BufferedImage (or some other Image) you can use its getRGB methods (or getRaster().getPixel). If you haven't, you can use JPanel's createImage methods and use the returned image to get the pixel data.

0

精彩评论

暂无评论...
验证码 换一张
取 消