Monday, October 15, 2012

Set Icon in Java Frames

Set the icon image in JFrame - you have to put the following code in to your constructor and change the image path most probably we are using 24 * 24 pixels .png image (here "/images/" is one of my packages)



[sourcecode language="java"]
public void Constuctor(){
this.setIconImage(new ImageIcon(getClass().getResource("/images/payroll.png")).getImage());
}

[/sourcecode]

Example of Jframe


Set the icon image in JInternalFrame

[sourcecode language="java"]
public void Constuctor(){
this.setFrameIcon(new ImageIcon(getClass().getResource("/images/Profile-24.png")));
}
[/sourcecode]

Example for JInternalFrame

No comments:

Post a Comment