Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Java Example Java Awt Setting the Icon for the frame in Java

Related Tutorials


Share on Google+Share on Google+

Setting the Icon for the frame in Java

In this section, you will learn how to set an icon for the frame in java.

Setting the Icon for the frame in Java



Here, 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. 

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.*;

public class AwtSetIconOfFrame{
public static void main(String[] args){
Frame frame = new Frame("Icon setting for the Awt Frame");
Image icon = Toolkit.getDefaultToolkit().getImage("icon_confused.gif");
Label lbl = new Label("Welcome in Tutorial.",Label.CENTER);

Download this example.


If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 17, 2007

Related Tutorials

Discuss: Setting the Icon for the frame in Java   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
March 8, 2012
IT helps

July 24, 2012

can we add actionListener to any label.. how can we use HyperLinks in JFrame...