Value Change Listener to JTextField

前端 未结 12 2174
情歌与酒
情歌与酒 2020-11-22 04:16

I want the message box to appear immediately after the user changes the value in the textfield. Currently, I need to hit the enter key to get the message box to pop out. Is

12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 04:23

    You can use even "MouseExited" to control. example:

     private void jtSoMauMouseExited(java.awt.event.MouseEvent evt) {                                    
            // TODO add your handling code here:
            try {
                if (Integer.parseInt(jtSoMau.getText()) > 1) {
                    //auto update field
                    SoMau = Integer.parseInt(jtSoMau.getText());
                    int result = SoMau / 5;
    
                    jtSoBlockQuan.setText(String.valueOf(result));
                }
            } catch (Exception e) {
    
            }
    
        }   
    

提交回复
热议问题