Custom method for the title bar icon of a Java application

Source: Internet
Author: User
The program I touch Java time is not long, but always want to be able to customize the Java Program title bar icon, but look for a lot of information this aspect of the introduction is very little.

Today, I stumbled upon the Java
Java.awt.Frame.setIconImage () method.

The routines are as follows:

Import javax.swing.*;

public class Java_titlebar_icon extends JFrame {
JLabel jlable1 = new JLabel ("Methods to demonstrate custom Java_titlebar_icon");
String image = new String ("Img/aa.gif"); Create a string to save the path to the icon you want to use, refer to the other documentation for the Java path
ImageIcon test = new ImageIcon (image); Create a ImageIcon class that produces the image data required by the Seticonimage () method

Public Java_titlebar_icon () {
Super ("How to demonstrate a custom Java_titlebar_icon");
This.seticonimage (Test.getimage ()); Set the icon for the title bar to Aa.gif
This.setdefaultcloseoperation (Jframe.exit_on_close);
JPanel pane = new JPanel ();
Pane.add (JLABLE1);
This.setcontentpane (pane);
This.show ();
}

public static void Main (string[] args) {
Java_titlebar_icon JtI = new Java_titlebar_icon ();
}
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.