title: Load a image in JPanel on button click
body: <p>I have seen many answers regarding this, but nothing seem to solve my problem, I have a jPanel1 and jPanel3 in a tabbed pane (same tab) and when I click a button from jPanel1 then I go to load an image in jPanel3.
  Here is how I am trying to do the same</p>
  
  <pre><code>jButton1.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
  
              System.out.println("In the action");
              try {
                  jPanel3.add(new JPanel(){
                      java.net.URL imgURL = this.getClass().getResource( "/resource/images/cd-dvd-icon.png");
                      BufferedImage image = ImageIO.read(imgURL);
                  });
                  jPanel3.revalidate();
                  jPanel3.repaint();
              } catch (IOException ex) {
                  ex.printStackTrace();
              }
          }
      });
  </code></pre>
  
  <p>But I am not seeing any error or the image also. Please help</p>