If you are building an application in netbeans , you may be stuck with icon . here am telling two different ways to set your application icon
first
************************
here you may create jframe class from right clicking on your package folder->new->jframe form.
so name of your main jframe will be hidden from you.In such a situation
step1
copy png image into your package folder containing same class
name to kk.pg(whatever you may like)
step2
copy this code
this.setIconImage(new ImageIcon(getClass().getResource("/JavaApplication6/kk.png")).getImage());
or you can split into three lines ,( i put these lines to understand the working principle... :-) )
// URL iconURL = getClass().getResource("/JavaApplication1/kk.png");
// ImageIcon icon = new ImageIcon(iconURL);
// this.setIconImage(icon.getImage());
here "this" means your java class
kk.png is located in your package folder
"JavaApplication6" is your package folder
second
****************
the second way you may use to create jframe manually
for example
JFrame frame1=new JFrame();
frame1.setIconImage(new ImageIcon(getClass().getResource("/JavaApplication6/kk.png")).getImage());
for such situation you can directly put your jframe name . here i created named frame1
first
************************
here you may create jframe class from right clicking on your package folder->new->jframe form.
so name of your main jframe will be hidden from you.In such a situation
step1
copy png image into your package folder containing same class
name to kk.pg(whatever you may like)
step2
copy this code
this.setIconImage(new ImageIcon(getClass().getResource("/JavaApplication6/kk.png")).getImage());
or you can split into three lines ,( i put these lines to understand the working principle... :-) )
// URL iconURL = getClass().getResource("/JavaApplication1/kk.png");
// ImageIcon icon = new ImageIcon(iconURL);
// this.setIconImage(icon.getImage());
here "this" means your java class
kk.png is located in your package folder
"JavaApplication6" is your package folder
second
****************
the second way you may use to create jframe manually
for example
JFrame frame1=new JFrame();
frame1.setIconImage(new ImageIcon(getClass().getResource("/JavaApplication6/kk.png")).getImage());
for such situation you can directly put your jframe name . here i created named frame1
0 Comments:
Post a Comment