Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Setting an Icon for a Frame in Java

                         

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

This program helps us to set the icon (image) on the title bar of the frame. When you open frame or window the icon situated on the title bar is seen on the taskbar also. For this purposes, various methods as follows has been used:

frame.setIconImage(Toolkit.getDefaultToolkit().getImage("icon_confused.gif"));
Above method sets the icon for the frame or window after getting the image using the Image class method named
getImage().

frame.getDefaultToolkit():
This is the method of the Toolkit class which gets the default toolkit.

Here is the code of program:

import javax.swing.*;
import java.awt.*;

public class SettingIconFrame{
  public static void main(String[] args){
    JFrame frame = new JFrame("Setting an Icon for a frame");
    frame.setIconImage(Toolkit.getDefaultToolkit().getImage("icon_confused.gif"));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400,400);
    frame.setVisible(true);
  }
}

Download this example.

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

11 comments so far (
post your own) View All Comments Latest 10 Comments:

I put an image called "icon_confused.gif" in the same location as the class, but no image is ever showing in the frame. Suggestions or explanations?

Posted by John on Friday, 09.26.08 @ 20:39pm | #80727

This tutorial provides an efficient way to learn java.it provides list of chapters incorporated.

Posted by somepallirajesh on Wednesday, 06.11.08 @ 14:29pm | #63008

This tutorial provides an efficient way to learn java.it provides list of chapters incorporated.

Posted by somepallirajesh on Wednesday, 06.11.08 @ 14:16pm | #63007

When i saw this site ,i felt very happy.Because all methos are available with program.

Posted by Govind on Thursday, 08.2.07 @ 14:13pm | #22482

Unable to see the image.

Pls help.

Thanks in advance

Posted by Balu on Wednesday, 03.7.07 @ 12:16pm | #10948

it is very nice site to understand the concepts of java

Posted by dillibabu.s on Tuesday, 02.27.07 @ 13:11pm | #9812

Is it really has to be .gif picture? cause I've tried with .ico and .jpg and it didn't work ;(

Posted by julia on Saturday, 01.13.07 @ 04:36am | #3318

I am a student in my second Java course at the University of Phoenix. I have been desperately trying to find a way to set a custom icon within the construct of JOptionPane.ShowMessageDialog. I have looked on Sun's web site, and I have searched high and low, but find it very difficult to find the information I am looking for.

Normally, an icon of an "i" with a circle appears to the left of the message displayed in an JOptionPane dialog. I simply want to replace that image with another icon that is a GIF file. I know this is theoretically possible, but would love any information you can provide on how to accomplish this goal.

Posted by Robert Hieger on Monday, 01.1.07 @ 11:55am | #2362

yaa its good

Posted by sendil on Saturday, 12.30.06 @ 16:44pm | #2260

Very helpful example.

Thanks!

Posted by Dave on Tuesday, 12.19.06 @ 19:33pm | #1270

Latest Searches:
pseudocode
Tomcat deploy JSP
Load
sort object compareTo
how to include jsf tag
source code of puzzle
sum of n integers
read a row in oracle t
mysql insert statement
Binary search java
calculate
validation for char le
clear the console in j
ejp
get column count colu
data binding
ะà???ะ ยà¸?ะà
permutation combinati
retreive numerical val
hibernate3.0 jar file
Photoshop Drawing 3D P
StringTokenizer specif
inventory
Error handling in stru
stored procedure
StringTokenizer select
LAMJ
JSP and MS access
tomcate 5.0 downloadab
videofile
url redirecting in ser
commands
flex
emailing file in java
standered jstl jar to
ะ�ะ�ะ�ะ?
Photoshop Textures and
arraylist of arraylist
append mesage
hibernate3.0 jar file
creating batch in sql
login session servlet
Date Examples java
Java Tuthreadstorials
JSF Data tree
Photoshop Textures and
insert query
Combattons la programm
ejb entity bean
PhotoshopTech/Abstract
Servlet Container
jstl list size
word
websphere portals
ASP.NET .NET Introduct
update mysql jsp
weblogic 10.3
Aå??ç?­??å??ç?­??å??ç?
fjhjf
jdbc connection
AOP
edit cell JTable
how to reload page aft
dynamic insert value J
ado
Hibernate API
Photoshop Textures and
passing value from ser
sequence number genera
jira Testing tool free
Murachâ?¨??â?¨??â?¨??â
toolsfordesigningacomp
Class Variables and Me
Linux Caixa MÑ?â??г?Ñ
SUBMITTING MULTIPLE FO
Reports
all ejb program
examples of sql
ASP Graphs and Charts
java jtable
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.