jComboBox1PopupMenuWillBecomeInvisible Event in Netbeans and set value on JTextField


private void jComboBox1PopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {                                                      
        String no=(String)jComboBox1.getSelectedItem();
          try
        {
    Class.forName("com.mysql.jdbc.Driver");
    java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/commity","root","root");
    String sql="select Cost from group1 where Group_Number='"+no+"'";
    java.sql.PreparedStatement pst=con.prepareStatement(sql);
   //pst.setString(1, no);
    ResultSet rs = pst.executeQuery(sql);
  
  while(rs.next())
  {
   double cost=rs.getDouble(1);
 jTextField8.setText(""+cost);
  }

con.close();
pst.close();
        }
        catch(Exception e)
        {
            System.out.println(e);
            JOptionPane.showMessageDialog(null, e);
        }
    }      

Popular posts from this blog

Simple Sign up design. Android.

Cart page design in android.

Set Date on jDateChooser and retrieve record from database.