title: Loading Image in Java using JFrame
body: <p>so i have a very basic java application, there is a panel and inside that is a button. When a user clicks the button, i want a picture to come up in another panel in the same form. </p>
  
  <p>I searched up ways to load images from web/from my folder and this is the code i've come up with:-</p>
  
  <pre><code>private void buttonActionPerformed(java.awt.event.ActionEvent evt)
  
  {                                       
      ImageIcon icon = new ImageIcon("URL-of-the-image");
      panel2.setIcon(icon);
  
  }    
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ruGRK.png" rel="nofollow noreferrer">~~what panel 2 looks like~~</a></p>
  
  <p>where am i going wrong?
  it says that the method "setIcon()" is causing a problem but i don't know any other method to do this job. Please Guide!</p>