Home Tutorial Java Swing Java Image On JFrame Title

 
 

Share on Google+Share on Google+
Java Image On JFrame Title
Posted on: October 23, 2009 at 12:00 AM
Advertisement
In this section, you will learn how to set an image on JFrame title Using Java Language.

How to set Image On JFrame

In this section, you will learn how to set an image on JFrame title using Java program. For this, we have created an object of JFrame class. Then, we have used Toolkit.getDefaultToolkit().getImage() that will load the specified image and the method setIconImage() of JFrame class have allowed  the image to be displayed on the JFrame title.

Here is the code:

import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.JLabel;
import javax.swing.JFrame;

public class ImageOnFrame {
  public static void main(String[] unused) {
    JFrame f = new JFrame("Frame");
    Image im = Toolkit.getDefaultToolkit().getImage("C:\\node.jpg");
  f.add(new JLabel("Hello World"));
    f.setIconImage(im);
    f.setSize(100100);
    f.setLocation(500500);
    f.setVisible(true);
  }
}
Advertisement

Related Tags for Java Image On JFrame Title:


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: October 23, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com