I have a textfield, and that only accept integer numbers. If user input charter type value it shows JOptionpane Error Message and when user click on the ok button in optionpane message the textfield clear itself
public void nosgetit(DocumentEvent documentEvent){
DocumentEvent.EventType type = documentEvent.getType();
if(type.equals(DocumentEvent.EventType.CHANGE)){
}
if(type.equals(DocumentEvent.EventType.INSERT)){
String ns=nos_txt.getText();
char [] c=ns.toCharArray();
for(int i=0; i < ns.length(); i++){
if ( !Character.isDigit(c[i])){
JOptionPane.showMessageDialog(null, "You must input number", "ERROR",
JOptionPane.ERROR_MESSAGE);
}
}
}
if(type.equals(DocumentEvent.EventType.REMOVE)){
}
}