This section illustrates you how the icon shows the Color Gradient.
A color gradient consisting of two or more colors blending together. To display the icon, we have defined the height and width of an image. To produce pixel values for an Image, we have used the class MemoryImageSource which is an implementation of the interface ImageProducer .
The method getPreferredSize() is used to determine the arrangement of layout and indicates the preferred size.
Following code draws the image:
|g.drawImage(image, 0, 0, getSize().width, getSize().height, this)|
Here is the code of IconShowingColorGradient.java
Output will be displayed as
Recommend the tutorial