#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    37
    Rep Power
    1

    SetIconImage not working


    My image is in the source folder and has a resolution of 32x32 but it still won't change the frame icon.

    Code:
    package pkgCarInsuranceCalc;
    
    // imports
    import javax.swing.*;
    
    public class Run 
    {
        
            public static void main(String[] args) 
            {
    	CarInsuranceCalc mainFrame = new CarInsuranceCalc();
    	mainFrame.setSize(600,450); // set frame dimensions
            mainFrame.setResizable(false);
    	mainFrame.setVisible(true); // make frame visible
            mainFrame.setLocationRelativeTo(null); // centre frame
            // close application when frame's X clicked
    	mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            // changes icon at the top left of the frame
            mainFrame.setIconImage(new ImageIcon("icon.gif").getImage());
    	} // end of main method
            
    }
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    Can you post a small, complete program that compiles, executes and shows the problem?

    Have you tried calling setVisible() after the code that sets up the GUI is finished?

IMN logo majestic logo threadwatch logo seochat tools logo