简体   繁体   English

值更改侦听器到JTextField

[英]Value Change Listener to JTextField

I want to know the equivalent event same like change event in VB i have text box field and i would like to trigger the code once user made any changes, in text box values ,i need to know how to stick listener to my text box currently am using KeyReleased event. 我想知道等效事件,例如VB中的change事件,我有文本框字段,并且我想在用户对文本框值进行任何更改后触发代码,我需要知道如何将侦听器粘贴到当前文本框正在使用KeyReleased事件。

 private void jTsearchKeyReleased(java.awt.event.KeyEvent evt) {  
 String jtr=jTsearch.getText();
 Boolean Txtval=StringUtils.isNumeric(jtr);
  if (Txtval=false) 
   // my code will come here 
  }
  }  
    jTsearch.getDocument().addDocumentListener(new DocumentListener() {
    public void changedUpdate(DocumentEvent e) {
        //whatever you want
    }
    public void removeUpdate(DocumentEvent e) {
       //whatever you want
    }
    public void insertUpdate(DocumentEvent e) {
      //whatever you want
    }
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM