?
Solved

Swing: Change icon

Posted on 2011-09-28
4
Medium Priority
?
254 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 2000 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

800 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