title: Change Icon in JFrame (get rid of the Cup)
body: <p>as an excercise I have to change the Icon of my JFrame to my companies logo.
  But no matter, what I try, it wont change.</p>
  
  <pre><code> public class window extends JFrame
  {
  private JTextField dateiname;
  
  JLabel textdatei;
  String[] choice = { "", "Berechtigung anlegen", "Tabelle erstellen",    "Stammdaten anlegen" };
  
  String intext="";
  JTextArea ausgabe = new JTextArea(intext,19,10);
  
  public      ImageIcon icon = new ImageIcon("tqg.JPG");
  public window()
  {
  
      super("SQL-Code-Vorlage");
      setLayout(new BorderLayout());
  
      setSize(400, 400);
      setIconImage(icon.getImage());
  </code></pre>
  
  <p>I put the "tqg.jpg" in the src folder, the main folder of the project, I also tried to put it in a folder /images. It just doesn't change the logo.</p>
  
  <p>//It has been fixed with this</p>
  
  <pre><code>  try
      {
          FileInputStream inputStream = new FileInputStream(new     File("tqg.png"));
  
          Image image = ImageIO.read(inputStream);
  
          this.setIconImage(image);
      } catch (IOException e1)
      {
  
          e1.printStackTrace();
      }
  </code></pre>
  
  <p>When you use jpg, ImageIcon asks for a coment and if there is none, you'll get a nullpointer exception.</p>