In this section, you will learn how to set an icon for the frame in java.
Setting the Icon for the frame in Java
IntroductionHere, you will learn how to set the icon of the frame.
This program is the detailed illustration to set the icon to the frame. Toolkit class has been used to get the image and then the image is used to display as frame icon. Toolkit class is used to bind the various components to particular native toolkit implementations.
getDefaultToolkit():
This method returns the default toolkit.
getImage(url or filename):
This method retrieves the pixels data of the image which can be either in
format of .gif, .jpeg
or .png. If the security manager installed
then the getImage() method first check whether the specified
file name has the permission to use and then retrieves the
image in pixels format.
Here is the code of the program :
import java.awt.*;
|