Solved

Swing: Change icon

Posted on 2011-09-28
4
226 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HSSFWorkbook cannot be resolved error 10 69
eclipse apache tomcat admin console 52 97
Java string replace 11 46
Is there a simpler dropbox system? 10 20
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

773 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