title: JCombobox value retrieve from My Sql
body: <p>I use the following code for retrieve the data from mysql Student data Base.It was work properly.It will show the student Name in combo box.The value is retrieved from Db.</p>
  
  <p>My problem is the first value(first student Name which is stored in Database column) displayed in the Jcombobox name field Automatically and it was show when I click Combo Box arrow..It means when I execute this following code I see the first value(first Name) in combobox's name field nearby arrow .But I need "Student Name" Title  in there.If i assign that design time but that same name displayed once again when i click that arrow.how to solve this?</p>
  
  <p>My another problem is how to get select "combo box items "when I type combo box's name field.It means if I type S means the combo box items selected which is started with S.</p>
  
  <pre><code>package designstudent;
  import java.awt.*;
  import java.awt.Point;
  import java.awt.Rectangle;
  import java.awt.event.*;
  import javax.swing.table.DefaultTableModel;
  import java.sql.*;
  import javax.swing.JOptionPane;
  import javax.swing.ListSelectionModel;
  import javax.swing.*;
  
  
  
  public class FrmeA extends javax.swing.JFrame  {
  
      FrmA1 f1=new FrmA1();
      Statement TmpFlxTSt=null;
      ResultSet TmpFlxTRs=null;
      GContnStr GCS=new GContnStr();
  
  public FrmeA() {
      initComponents();
  }
  
  public void combo() {
  
      try {
          GCS.GContnStr();
          TmpFlxTSt= GCS.GCotnStr.createStatement();
          String select = "Select StudName from studentmaster";
          TmpFlxTRs = TmpFlxTSt.executeQuery(select);
  
          while (TmpFlxTRs.next()) {
              cbx.addItem(TmpFlxTRs.getString("StudName"));
              Object comboitem=cbx.getSelectedItem();
          }
  
          TmpFlxTRs.close();
          TmpFlxTSt.close();
      }
      catch(Exception e) {
          System.out.println(e);
      }
  
  }
  
  
  @SuppressWarnings("unchecked")
  // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt;
  private void initComponents() {
  
      jPanel1 = new javax.swing.JPanel();
      jPanel2 = new javax.swing.JPanel();
      CmdA = new javax.swing.JButton();
      CmdE = new javax.swing.JButton();
      CmdD = new javax.swing.JButton();
      cmdQ = new javax.swing.JButton();
      jPanel3 = new javax.swing.JPanel();
      jScrollPane1 = new javax.swing.JScrollPane();
      FlxT = new javax.swing.JTable();
      cbx = new javax.swing.JComboBox();
  
      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
      jPanel2.setBorder(
          javax.swing.BorderFactory.createTitledBorder(
              javax.swing.BorderFactory.createMatteBorder(
                  1, 1, 1, 1, new java.awt.Color(0, 0, 255
              )
          ), "Commands")
      );
  
      CmdA.setFont(new java.awt.Font("Arial", 0, 10));
      CmdA.setText("+");
      CmdA.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
              CmdAActionPerformed(evt);
          }
      });
  
      CmdE.setFont(new java.awt.Font("Arial", 0, 10));
      CmdE.setText("E");
  
      CmdD.setFont(new java.awt.Font("Arial", 0, 10));
      CmdD.setText("-");
  
      cmdQ.setFont(new java.awt.Font("Arial", 0, 10));
      cmdQ.setText("Q");
      javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
      jPanel2.setLayout(jPanel2Layout);
      jPanel2Layout.setHorizontalGroup(
      jPanel2Layout.createParallelGroup(
          javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(jPanel2Layout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(
                CmdA,javax.swing.GroupLayout.PREFERRED_SIZE,64,javax.swing.GroupLayout.PREFERRED_SIZE
                   )
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addComponent(CmdE, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addComponent(CmdD, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addComponent(cmdQ, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addGap(35, 35, 35))
          );
  
          jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {CmdA, CmdE, cmdQ});
  
          jPanel2Layout.setVerticalGroup(
              jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(jPanel2Layout.createSequentialGroup()
                  .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                      .addComponent(CmdA, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addComponent(CmdE, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
                      .addComponent(CmdD, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
                      .addComponent(cmdQ, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE))
                  .addContainerGap())
          );
  
          jPanel3.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
  
          FlxT.setFont(new java.awt.Font("Arial", 0, 10));
          FlxT.setModel(new javax.swing.table.DefaultTableModel(
              new Object [][] {
  
              },
              new String [] {
                  "StudName", "StudClass", "StudMrk1", "StudMrk2", "StudTot", "StudRes", "StudNO", "StudId"
              }
          ) {
              Class[] types = new Class [] {
                  java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class
              };
  
              public Class getColumnClass(int columnIndex) {
                  return types [columnIndex];
              }
          });
          jScrollPane1.setViewportView(FlxT);
          FlxT.getColumnModel().getColumn(0).setResizable(false);
          FlxT.getColumnModel().getColumn(0).setPreferredWidth(150);
          FlxT.getColumnModel().getColumn(1).setResizable(false);
          FlxT.getColumnModel().getColumn(1).setPreferredWidth(70);
          FlxT.getColumnModel().getColumn(2).setResizable(false);
          FlxT.getColumnModel().getColumn(2).setPreferredWidth(70);
          FlxT.getColumnModel().getColumn(3).setResizable(false);
          FlxT.getColumnModel().getColumn(3).setPreferredWidth(70);
          FlxT.getColumnModel().getColumn(4).setResizable(false);
          FlxT.getColumnModel().getColumn(4).setPreferredWidth(70);
          FlxT.getColumnModel().getColumn(5).setResizable(false);
          FlxT.getColumnModel().getColumn(5).setPreferredWidth(70);
          FlxT.getColumnModel().getColumn(6).setMinWidth(0);
          FlxT.getColumnModel().getColumn(6).setPreferredWidth(0);
          FlxT.getColumnModel().getColumn(6).setMaxWidth(0);
          FlxT.getColumnModel().getColumn(7).setMinWidth(0);
          FlxT.getColumnModel().getColumn(7).setPreferredWidth(0);
          FlxT.getColumnModel().getColumn(7).setMaxWidth(0);
  
          javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
          jPanel3.setLayout(jPanel3Layout);
          jPanel3Layout.setHorizontalGroup(
              jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGap(0, 1015, Short.MAX_VALUE)
              .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(jPanel3Layout.createSequentialGroup()
                      .addContainerGap()
                      .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 995, Short.MAX_VALUE)
                      .addContainerGap()))
          );
          jPanel3Layout.setVerticalGroup(
              jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGap(0, 249, Short.MAX_VALUE)
              .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(jPanel3Layout.createSequentialGroup()
                      .addContainerGap()
                      .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addContainerGap(54, Short.MAX_VALUE)))
          );
  
          cbx.setEditable(true);
          cbx.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
          cbx.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  cbxActionPerformed(evt);
              }
          });
  
          javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
          jPanel1.setLayout(jPanel1Layout);
          jPanel1Layout.setHorizontalGroup(
              jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                  .addContainerGap(657, Short.MAX_VALUE)
                  .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addContainerGap())
              .addGroup(jPanel1Layout.createSequentialGroup()
                  .addGap(122, 122, 122)
                  .addComponent(cbx, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addContainerGap(791, Short.MAX_VALUE))
              .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(jPanel1Layout.createSequentialGroup()
                      .addContainerGap()
                      .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                      .addContainerGap()))
          );
          jPanel1Layout.setVerticalGroup(
              jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(jPanel1Layout.createSequentialGroup()
                  .addGap(19, 19, 19)
                  .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addGap(18, 18, 18)
                  .addComponent(cbx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addContainerGap(777, Short.MAX_VALUE))
              .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(jPanel1Layout.createSequentialGroup()
                      .addGap(190, 190, 190)
                      .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addContainerGap(503, Short.MAX_VALUE)))
          );
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGap(0, 1047, Short.MAX_VALUE)
              .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(layout.createSequentialGroup()
                      .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGap(0, 955, Short.MAX_VALUE)
              .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(layout.createSequentialGroup()
                      .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
          );
  
          pack();
          java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
          java.awt.Dimension dialogSize = getSize();
          setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
      }// &lt;/editor-fold&gt;
  
      private void CmdAActionPerformed(java.awt.event.ActionEvent evt) {                                     
  
          f1.setVisible(true);
  
   // TODO add your handling code here:
      }                                    
  
      private void cbxActionPerformed(java.awt.event.ActionEvent evt) {
  
  }
  
      public static void main(String args[]) {
          java.awt.EventQueue.invokeLater(new Runnable() {
              public void run() {
                   FrmeA fr=new FrmeA();
                   fr.combo();
                   fr.setVisible(true);
                     //fr.initconn();
              }
          });
      }
  
      // Variables declaration - do not modify
      private javax.swing.JButton CmdA;
      private javax.swing.JButton CmdD;
      private javax.swing.JButton CmdE;
      private javax.swing.JTable FlxT;
      private javax.swing.JComboBox cbx;
      private javax.swing.JButton cmdQ;
      private javax.swing.JPanel jPanel1;
      private javax.swing.JPanel jPanel2;
      private javax.swing.JPanel jPanel3;
      private javax.swing.JScrollPane jScrollPane1;
      // End of variables declaration
  }
  </code></pre>