title: Why/When ComponentListener.componentShown() get invoked?
body: <p>Why this code never prints "Hello2"  ?</p>
  
  <pre><code>public class Test4 {
  
      public static void main(String[] args) {
          JFrame f = new JFrame();
          JPanel p = new JPanel();
          f.getContentPane().add(p);
  
          JLabel x = new JLabel("Hello");
          p.add(x);
  
          p.addComponentListener(new ComponentListener() {
  
              public void componentResized(ComponentEvent arg0) {
                   System.err.println("Hello1");
              }
  
              public void componentMoved(ComponentEvent arg0) {
              }
  
              public void componentShown(ComponentEvent arg0) {
                  System.err.println("Hello2");
              }
  
              public void componentHidden(ComponentEvent arg0) {
              }
          });
  
          f.setVisible(true);
          f.pack();
      }
  }
  </code></pre>