Pages

Sunday, November 20, 2011

tips Of java 1:Changing The Icon of Java frame

By default java frame have the icon in the picture below
. Here i am going to explain a way to change the icon of java frame.
Create jframe using JFrame f=new JFrame("sample");
Set static java.net.URL imgURL = Window.class.getResource("images/icon.jpg");
Call f.setIconImage(getFDImage());
function getFDImage()
protected static Image getFDImage() {
        if (imgURL != null) {
            return new ImageIcon(imgURL).getImage();
        } else {
            return null;
           
        }
 }
This will change the icon to icon.jpg put this file into images folder.
Changed Icon



No comments:

Post a Comment