title: Swing Jcombobox set first element as default selected
body: <pre><code>    String[] bookArray={"a","b","c"};
      JComboBox bookComboBox = new JComboBox(bookArray);
      bookComboBox.setSelectedIndex(0);
      bookComboBox.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              JComboBox cb= (JComboBox) e.getSource();
              bookNameSelected=(String) cb.getSelectedItem();
              System.out.println("book name selected:"+bookNameSelected);
              }
      });
  </code></pre>
  
  <p>First element of drop down is shown as default but not passed as default selected value if user does not select any value.</p>