Solved

Swing: Change icon

Posted on 2011-09-28
4
236 Views
Last Modified: 2012-05-12
Is it possible to change the icon that appears at the top-left corner of the title bar in any Swing window? By default, it is the java logo.

If yes, please let me know how. Thanks!
0
Comment
Question by:dshrenik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36718286
check here:
http://www.java-forums.org/awt-swing/5373-how-change-window-icon.html

    In the Netbeans properties window for your form, try iconImage. Otherwise, try:
    Java Code:
    1
    2
          
    Image icon = Toolkit.getDefaultToolkit().getImage([COLOR=#0066ff]"icon.gif"[/COLOR]);
    frame.setIconImage(icon);

0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36718323
Yes, i tried, and it acuatlly worked for me like that:
 public MyFrame(){
        super("My Frame");
        Image icon = Toolkit.getDefaultToolkit().getImage("icon.gif");
           this.setIconImage(icon);
....
   

Open in new window

0
 

Author Comment

by:dshrenik
ID: 36718490
The above code is in the constructor of my class that extends JFrame?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36718495
Yes, exactly
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ejb entity bean example 2 57
Java 8 to Java 6 8 43
junit example issue 2 54
Eclipse neon2 "Java build path" correctness 7 43
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question