java - How can I real time check for exceptions after JTextField has been entered -
say have input field take int
when submit button pressed.
how can disable button should field check not int
.
ignore add number
button it's irrelevant.
you could utilize documentlistener
:
document document = jtextfiled.getdocument(); document.adddocumentlistener(new documentlistener() { @override public void insertupdate(documentevent e) { check(); } @override public void removeupdate(documentevent e) { check(); } @override public void changedupdate(documentevent e) { check(); } private void check() { if (!isinteger(jtextfiled.gettext())) { jbutton.setenabled(false); } else { jbutton.setenabled(true); } } });
java exception
No comments:
Post a Comment