I'm a newb to GUI and I'm trying to wrap my head around it. I don't quite understand why I am unable to change the frame icon in my GUI application. I chose a picture from "my Pictures" and entered the file's name as a string. However the icon never changes. Please explain why it is true and what can be done to solve this issue.
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package practice; import java.awt.*; import java.awt.image.ImageObserver; import java.awt.image.ImageProducer; import java.io.File; import java.io.IOException; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; /** * * */ public class Practice extends JFrame { public Practice(){ super("MyEmptyFrame"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Toolkit tk = Toolkit.getDefaultToolkit(); Image frameIcon = tk.getImage("002.jpg"); setIconImage(frameIcon); setExtendedState(MAXIMIZED_BOTH); } public static void main(String[] args) { Practice frame = new Practice(); frame.setVisible(true); } }