title: How to change java icon in a JFrame
body: <p>Ok so I've been researching this one quiet a bit. I am fairly new to java but thought that this one would be easy. Ive tried just about every way that has been answered on this site and still no luck, and usually when I look here I am able to find a answer that fits what I am looking for. Does anyone know how to change the Java icon in the top corner of the JFrame. I'm pretty positive that its not my file path either because all my images are in the same folder and they all work, this is the only one that I can't seem to get to work.</p>
  
  <p>This is the first part my code for the main menu of my program, everything works except when i try to add the icon image. The code I've entered below does not have anything in it for the JFrame IconImage, I removed it since it didn't work. So if there is someone who knows how to get it working with this code that would be highly appreciated, thank you very much in advanced!</p>
  
  <pre><code>public class MainFrame
  {
  private MyPanel main;
  private MyPanel2 create;
  private MyPanel3 update;
  private MyPanel4 find;
  JFrame frame = new JFrame("Main Menu:");
  
  public void displayGUI()
  {
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JPanel contentPane = new JPanel();
      contentPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      contentPane.setLayout(new CardLayout());
      main = new MyPanel(contentPane, this);
      create = new MyPanel2(contentPane);
      update = new MyPanel3(contentPane);
      find = new MyPanel4(contentPane);
      contentPane.add(main, "Main Menu");
      contentPane.add(create, "Create Part");
      contentPane.add(update, "Update Part");
      contentPane.add(find, "Find Part");
      frame.setLocation(200, 200);
      frame.setSize(700, 580);
      frame.setContentPane(contentPane);
  
      frame.setVisible(true);
  
  }
  </code></pre>