Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
The setIconImage() method of the Frame class is used to change the icon of Frame or Window. It changes the icon on the left side of the Frame or Window. The Toolkit class is used to get an instance of the Image class in AWT and Swing. Toolkit class is the abstract superclass of every implementation in the Abstract Window Toolkit(AWT). Subclasses of Toolkit are used to bind various components. It inherits the Object class.
Example to change TitleBar icon in Java AWT
import java.awt.*;
class IconExample {
IconExample(){
Frame f=new Frame();
Image icon = Toolkit.getDefaultToolkit().getImage("D:\\icon.png");
f.setIconImage(icon);
f.setLayout(null);
f.setSize(500,500);
f.setVisible(true);
}
public static void main(String args[]){
new IconExample();
}
}
You can also try this code with Online Java Compiler
The setIconImage() method of the Frame class is used to change the icon of Frame or Window.
What is used to get an instance of the image in AWT?
Toolkit Class is used to get an instance of the image in AWT.
Define Toolkit class.
Toolkit class is the abstract superclass of every implementation in the Abstract Window Toolkit(AWT).
What is the use of Subclasses?
Subclasses of Toolkit are used to bind various components. It inherits the Object class.
Which command is used to set the size of TitleBar?
setSize command is used to set the size of TitleBar.
Conclusion
After reading about Change Title Icon in Java Swing are you not feeling excited to read/explore more articles on Java Swing? Don't worry; Coding Ninjas has you covered.
However, you may want to pursue our premium courses to give your job an advantage over the competition!