title: textfield with actionperformed actionlistner
body: <p>I have a jTextField and a jLabel. And I want to get data from database to my label automatically after user finished typing.</p>
  
  <pre><code>subcode_txt.addKeyListener(new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
              Object obj=e.getSource();
              if(obj==subcode_txt){
              jst=subcode_txt.getText();
              try{
  
              rs=st.executeQuery("Select * from facultydtls where sub_code like '"+jst+"'");
              rs.next();
              faculty_lab.setText(rs.getString("f_name"));
              sem_lab.setText(rs.getString("sem"));
              subject_lab.setText(rs.getString("sub"));
              department_lab.setText(rs.getString("dept"));
  
              rs.close();
  
          }
          catch(Exception ewt){
              JOptionPane.showMessageDialog(null,"Invalid Subject Code");
          }
              }
          }
      });
  </code></pre>