im trying to validate a jtextfield
from the keypress
and would like it to throw an error message in a jLabel
. I am trying to do this with in the code below.
private void jTextField2KeyPressed(java.awt.event.KeyEvent evt) {
}
im trying to validate a jtextfield
from the keypress
and would like it to throw an error message in a jLabel
. I am trying to do this with in the code below.
private void jTextField2KeyPressed(java.awt.event.KeyEvent evt) {
}
Can't comment, so i'll answer instead. If you are looking to validate the input of the user as he/she type, you might wanna have a look at javax.swing.text.DocumentFilter.
If you are simply looking to update a JLabel when the user types something, you should add a KeyboardListener to the JTextField. You have to be a bit careful with that tho, as swing doesn't guarantee the order in which listeners are called, meaning that the text may not have updated when the KeyboardListener is invoked.