input - Java: How to disable JSpinner beeping -


when invalid input entered jspinner, beep played, , can't figure out how disable it.

i'm using number spinner invalid input not being allowed typed in, so:

public class spinnertester {      public static void main(string[] args) {          jspinner spinner = new jspinner(new spinnernumbermodel(1, 0, 100, 1));           //disable invalid input being typed spinner         jformattedtextfield textfield = ((jspinner.numbereditor) spinner.geteditor()).gettextfield();         ((numberformatter) textfield.getformatter()).setallowsinvalid(false);          jframe frame = new jframe();         frame.setdefaultcloseoperation(windowconstants.exit_on_close);         frame.add(spinner);         frame.setvisible(true);         frame.pack();     }  } 

i not know if there better way, 1 way make custom , feel disables beeping altogether. achieves desired effect, disables beeping entire program, not spinner.

public class spinnertester {      public static void main(string[] args) {          jspinner spinner = new jspinner(new spinnernumbermodel(1, 0, 100, 1));           //disable invalid input being typed spinner         jformattedtextfield textfield = ((jspinner.numbereditor) spinner.geteditor()).gettextfield();         ((numberformatter) textfield.getformatter()).setallowsinvalid(false);          /**          * change , field          */         try {             uimanager.setlookandfeel(new mylookandfeel());         } catch (unsupportedlookandfeelexception e) {             e.printstacktrace();         }          jframe frame = new jframe();         frame.setdefaultcloseoperation(windowconstants.exit_on_close);         frame.add(spinner);         frame.setvisible(true);         frame.pack();      }      /**      * create , feel without beeps      */     public static class mylookandfeel extends nimbuslookandfeel {         @override         public void provideerrorfeedback(component component) {             //super.provideerrorfeedback(component);         }     } } 

based off answer this question.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo