Questions tagged «documentlistener»

12
值更改侦听器到JTextField
我希望消息框在用户更改文本字段中的值后立即出现。目前,我需要按Enter键才能弹出消息框。我的代码有什么问题吗? textField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (Integer.parseInt(textField.getText())<=0){ JOptionPane.showMessageDialog(null, "Error: Please enter number bigger than 0", "Error Message", JOptionPane.ERROR_MESSAGE); } } } 任何帮助,将不胜感激!
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.