title: How to display images selected from a ComboBox
body: <p>When I compile, I have a blank window. No elements are being added to the main frame. What am I missing?</p>
  
  <pre><code>public class Gui extends JFrame {
      private JComboBox&lt;String&gt; box;
      private JLabel picture;
      private static String[] filename = {"pic1", "pic2.png" };
      private Icon[] pics = { new ImageIcon(getClass().getResource(filename[0])),
              new ImageIcon(getClass().getResource(filename[1])) };
  
      Gui() {
          super("window");
          setLayout(new FlowLayout());
          setVisible(true);
          setSize(600, 500);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          box = new JComboBox&lt;String&gt;(filename);
          box.addItemListener(new ItemListener() {
              public void itemStateChanged(ItemEvent e) {
                  if (e.getStateChange() == ItemEvent.SELECTED) {
                      picture.setIcon(pics[box.getSelectedIndex()]);
                  }
              }
          });
          picture = new JLabel(pics[0]);
          add(picture);
          add(box);
      }
  }
  </code></pre>