This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi all, Is there an easy way or any way of getting the background color of an imageicon. Do tell me if this is a stupid question, because from my angle it appears to be valid. I have an ImageIcon that has a green background, I would like to set the background of the panel that I'm placing it on the same color. thanks. Sarone
Since an ImageIcon is created from Image data (i.e gif, jpeg) I assume the background you are trying to determine is part of the image. The only way I know to determine the bg would be to use a PixelGrabber for the image and determine its color model. However to do this you would have to either 1) know the x,y of a background pixel or 2) write a method that examines every pixel and determines the background based upon the most occurences of any one Color(this is obviously not perfect). If you know, the image color going in, you would be better off just getting the Color values (r,g,b,a) from your image editing program and then coding in this color. Kyle