title: How to display my Image from a URL into my JLabel (JFrame)
body: <p>Hello guys i am trying to display a picture from a URL on my JFrame,
  but its not working. Here is the code below: Note that MYJ is the name
  of my JLabel. I showed a tutorial here already but when I am  trying to work with it, it displays on a separate label that was already created.</p>
  
  <pre><code>    import java.awt.Image;
      import java.io.IOException;
      import java.net.URL;
      import javax.imageio.ImageIO;
      import javax.swing.ImageIcon;
      import javax.swing.JLabel;
  
  
      public class MYPIX extends javax.swing.JFrame {
      public void myFrame (){
  
      }
  
      /**
       * Creates new form MYPIX
       */
      public MYPIX() {
          initComponents();
  
              Image image = null;
          try {
              URL url = new URL("http://i.imgur.com/xiVXrCD.jpg");
              image = ImageIO.read(url);
          } catch (IOException e) {
              e.printStackTrace();
  
                   ImageIcon I22 = new ImageIcon();
                          MYJ.setIcon(I22);
          }
  
      }
  
       public static void main(String args[]) {
  
      java.awt.EventQueue.invokeLater(new Runnable() {
              public void run() {
                  new MYPIX().setVisible(true);
              }
          });
      }
       private javax.swing.JLabel MYJ;
      // End of variables declaration                   
      }
  </code></pre>