java - Validating a text field with int value -


i'm using netbeans ide want validate text field use type discount percentage. want stop typing numbers more 100 in keytyped event.

can me solve problem

don't use keylisteners try , filter text components.

instead...

updated example

import java.awt.borderlayout; import java.awt.eventqueue; import java.awt.gridbaglayout; import javax.swing.jframe; import javax.swing.jspinner; import javax.swing.uimanager; import javax.swing.unsupportedlookandfeelexception;  public class testspinner02 {      public static void main(string[] args) {         new testspinner02();     }      public testspinner02() {         eventqueue.invokelater(new runnable() {             @override             public void run() {                 try {                     uimanager.setlookandfeel(uimanager.getsystemlookandfeelclassname());                 } catch (classnotfoundexception | instantiationexception | illegalaccessexception | unsupportedlookandfeelexception ex) {                 }                  jspinner spinner = new jspinner();                 spinner.setmodel(new javax.swing.spinnernumbermodel(0, 0, 100, 1));                  jframe frame = new jframe("testing");                 frame.setdefaultcloseoperation(jframe.exit_on_close);                 frame.setlayout(new gridbaglayout());                 frame.add(spinner);                 frame.pack();                 frame.setlocationrelativeto(null);                 frame.setvisible(true);             }         });     }  } 

Comments