How to extends JSpinner to check for input validation.

I have JSpinner instantiated with a SpinnerNumberModel. If I enter a number for example 123 I am happy with it. However if enter 12a3, I would like the spinner to the notify the user of the error, instead of parsing the number to just 12.
Thank you.

The text component of a JSpinner that uses numbers is a called a NumberEditor and is an inner class of JSpinner. You can read the API here
It uses a JFormattedTextField to accept input, and you would do well to read the API on this as well. You may need to substitute a plain JTextField with a DocumentListener, but I haven't tried this so can't fully vouch for this.
oh, and as always, please simply ignore alexxzius.
Edited by: Encephalopathic on Jul 4, 2008 11:25 AM

Similar Messages

  • How to extend  breadth first Search for Binary Tree to any kind of Tree??

    Dear Friends,
    I am thinking a problem, How to extend breadth first Search for Binary Tree to any kind of Tree?? ie each node has more than 2 leaves such as 1, 2,3,4 or any,
    I have following code to successfully apply for breadth first Search in Binary Tree as follows,
    package a.border;
    import java.util.ArrayList;
    import java.util.LinkedList;
    public class Tree
        int root;
        Tree left;
        Tree right;
        static ArrayList<Integer> list = new ArrayList<Integer>();
        static ArrayList<Tree> treeList = new ArrayList<Tree>();
        private static LinkedList<Tree> queue = new LinkedList<Tree>();
         * @param root root value
         * @param left left node
         * @param right right node
        public Tree(int root, Tree left, Tree right)
            this.root = root;
            this.left = left;
            this.right = right;
        /** Creates a new instance of Tree
         * You really should know what this does...
         * @param root
        public Tree(int root)
            this.root = root;
            this.left = null;
            this.right = null;
         * Simply runs a basic left then right traversal.
        public void basicTraversal()
            //Check if we can go left
            if (left != null)
                left.basicTraversal();
            //Add the root
            list.add(root);
            //Check if we can go right
            if (right != null)
                right.basicTraversal();
        public ArrayList<Integer> getBreadthTraversal(ArrayList<Integer> list)
            //Add the root to the arraylist, we know it is always the first entry.
            list.add(root);
            //Basically we add the first set of nodes into the queue for
            //traversing.
            //Query if left exists
            if (left != null)
                //Then add the node into the tree for traversing later
                queue.add(left);
            //Same for right
            if (right != null)
                queue.add(right);
            //Then we call the traverse method to do the rest of the work
            return traverse(list);
        private ArrayList<Integer> traverse(ArrayList<Integer> list)
            //Keep traversing until we run out of people
            while (!queue.isEmpty())
                Tree p = queue.remove();
                //Check if it has any subnodes
                if (p.left != null)
                    //Add the subnode to the back of the queue
                    queue.add(p.left);
                //Same for left
                if (p.right != null)
                    //Same here, no queue jumping!
                    queue.add(p.right);
                //Append to the ArrayList
                list.add(p.root);
            //And return
            return list;
         * Makes a tree and runs some operations
         * @param args
        public static void main(String[] args)
             *                             4
             *          t =           2       6
             *                      1   3    5   7
            Tree leaf6 = new Tree(1);
            Tree leaf7 = new Tree(3);
            Tree leaf8 = new Tree(5);
            Tree leaf9 = new Tree(7);
            Tree t4 = new Tree(2, leaf6, leaf7);
            Tree t5 = new Tree(6, leaf8, leaf9);
            Tree t = new Tree(4, t4, t5);
            t.basicTraversal();
            System.out.println("Here is basicTraversal ="+list.toString());
            list.clear();
            t.getBreadthTraversal(list);
            System.out.println("getBreadthTraversal= " +list.toString());
            list.clear();
        }Can Guru help how to update to any kind of tree??
    here this code is for the tree like:
             *                             4
             *          t =           2       6
             *                      1   3    5   7
             */But i hope the new code can handle tree like:
             *                             4
             *                           /   | \
             *                          /     |   \
             *          t =            2     8   6
             *                        / |  \    |    /| \
             *                      1 11  3 9   5 10  7
             */Thanks

    sunnymanman wrote:
    Dear Friends,
    I am thinking a problem, How to extend breadth first Search for Binary Tree to any kind of Tree?? ...The answer is interfaces.
    What do all trees have in common? And what do all nodes in trees have in common?
    At least these things:
    interface Tree<T> {
        Node<T> getRoot();
    interface Node<T> {
        T getData();
        List<Node<T>> getChildren();
    }Now write concrete classes implementing these interfaces. Let's start with a binary tree (nodes should have comparable items) and an n-tree:
    class BinaryTree<T extends Comparable<T>> implements Tree<T> {
        protected BTNode<T> root;
        public Node<T> getRoot() {
            return root;
    class BTNode<T> implements Node<T> {
        private T data;
        private Node<T> left, right;
        public List<Node<T>> getChildren() {
            List<Node<T>> children = new ArrayList<Node<T>>();
            children.add(left);
            children.add(right);
            return children;
        public T getData() {
            return data;
    class NTree<T> implements Tree<T> {
        private NTNode<T> root;
        public Node<T> getRoot() {
            return root;
    class NTNode<T> implements Node<T> {
        private T data;
        private List<Node<T>> children;
        public List<Node<T>> getChildren() {
            return children;
        public T getData() {
            return data;
    }Now with these classes, you can wite a more generic traversal class. Of course, every traversal class (breath first, depth first) will also have something in common: they return a "path" of nodes (if the 'goal' node/data is found). So, you can write an interface like this:
    interface Traverser<T> {
        List<Node<T>> traverse(T goal, Tree<T> tree);
    }And finally write an implementation for it:
    class BreathFirst<T> implements Traverser<T> {
        public List<Node<T>> traverse(T goal, Tree<T> tree) {
            Node<T> start = tree.getRoot();
            List<Node<T>> children = start.getChildren();
            // your algorithm here
            return null; // return your traversal
    }... which can be used to traverse any tree! Here's a small demo of how to use it:
    public class Test {
        public static void main(String[] args) {
            Tree<Integer> binTree = new BinaryTree<Integer>();
            // populate your binTree
            Tree<Integer> nTree = new NTree<Integer>();
            // populate your nTree
            Traverser<Integer> bfTraverser = new BreathFirst<Integer>();
            // Look for integer 6 in binTree
            System.out.println("bTree bfTraversal -> "+bfTraverser.traverse(6, binTree));
            // Look for integer 6 in nTree
            System.out.println("bTree bfTraversal -> "+bfTraverser.traverse(6, nTree));
    }Good luck!

  • How to stop Firefox from checking for add-on compatibility every time it opens?

    How to stop Firefox from checking for add-on compatibility every time it opens?

    That can be a problem with the compatibility.ini file in the Firefox profile folder.
    Try to rename (or delete) the compatibility.ini file in the Firefox profile folder to see if that helps.
    You can use this button to go to the currently used Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Show Folder (Linux: Open Directory; Mac: Show in Finder)
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    You can also check for problems with preferences.
    Delete possible user.js and numbered prefs-##.js files and rename (or delete) the prefs.js file to reset all prefs to the default value including prefs set via user.js and prefs that are no longer supported in the current Firefox release.
    *http://kb.mozillazine.org/Preferences_not_saved
    *http://kb.mozillazine.org/Resetting_preferences

  • How to do the Unicode Check for Business Objects ?

    Hi all,
    How to do the Unicode Check for Business Objects ?
    Note: All business Objects are stored in BOR (Business Objects Repositary)
    Thanks in advance
    Sri..

    Hi..
    i have used the  UCCHECK  transaction for some business Objects
    For some business objects it is showing that No Unicode Errors found Ex: Z00MARA
    and for Business Objects it showing the message like : There is no program corresponding to this selection.
    Why system is showing like this ?
    Thanks in advance
    Sri..

  • How to keep the field open for input with error message in report program

    Hi,
      Need a help in solving the below issue.
    "How to keep the field open for input with error message in report program"
    Regards,
    C.Shasiraj.

    Hi...
    you have to use the event:
    <b>AT SELECTION-SCREEN ON <FIELD> EVENT.</b>
    u have to give an error message in this event.
    Consider the following <b>Example:</b>
    <b>PARAMETERS : NUMBER TYPE I.
    AT SELECTION-SCREEN ON NUMBER.
      IF NUMBER = 10.
        MESSAGE 'Number vakue is 10' TYPE 'E'.
      ENDIF.
    START-OF-SELECTION.
      WRITE NUMBER.
    </b>
    in this if u give the value of number = 10, it will not proceed further, if u give some other value other than 10 you will proceed further...
    Execute this program once u will understand....
    also Consider the following links :
    <b>Regarding events:</b>
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/79/34a237d9b511d1950e0000e8353423/frameset.htm
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/79/34a23ad9b511d1950e0000e8353423/frameset.htm
    <b>Regarding messages:</b>
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/c5/aa575426ad11d2954d0000e8353423/frameset.htm
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/c5/aa575426ad11d2954d0000e8353423/frameset.htm
    This is very useful.......
    Reward points if useful....
    Suresh....

  • How to extend the time line for the premiere on mac pro mavericks

    how to extend the time line for the premiere on mac pro mavericks

    Wrong place.
    Try the Adobe Premiere forum.
    http://forums.adobe.com/community/premiere
    Good luck,
    x

  • How to extend the costing view for a material

    How to extend the costing view for a material

    Use MM01 Trxn code and Select Material and Select Costing Views and Maintain, Save it.
    Else Use MM50 and Select Material and Mainenance Status as G Costing and Execute, Maintain & Save.

  • How to extend AVK to scan for other vendor-specific APIs?

    All--
    How do I extend AVK to scan for other vendor specific APIs.
    I tried adding another <name> element underneath the
    appropriate the <unsupported> tag in the asmt-config.xml file,
    e.g.
    <websphere50>
    <supported>
    </supported>
    <unsupported>
    <name>com.ibm.ws.activity.ActivityConstants</name>
    .......... other <name> elements were left alone ..........
    </unsupported>
    </websphere50>
    But when I scanned the source code it didn't find an import of that API.
    Note: it did find an import of the APIs that were pre-defined in the asmt-
    config file; just not the one that I added.
    Is adding a <name> to the asmt-config.xml file the right approach?
    If so, how does the SourceScan ant task know where to find the asmt-
    config.xml file. Currently, I left it in the %JAVKE_HOME%/config folder.
    Is that the right place for that file?
    Any comments on how to extend AVK to scan for other vendor
    specific APIs would be greatly appreciated.

    Oops!
    Its probably bad form to answer your own question, but after
    sending out the original post, I treid:
    1. opening a new shell
    2. running the %JAVKE_HOME%/bin/javke_setenv.bat
    3. then ran the "asant code-scan" from that shell and viola it worked ...
    Sorry for any confusion.

  • How come when I go check for my purchased apps on my iPod touch 4g ios 6.1 it loads long then it crashes. Can this be fixed ?

    How come when I go check for my purchased apps on my iPod touch 4g ios 6.1 it loads long then it crashes. Can this be fixed ?

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.alredy suggested
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
      Apple Retail Store - Genius Bar

  • How to set default email address for input

    G'day all
    Summary: I'm sick, it's difficult to type, and a combination of autocorrect, default Shift key settings for input fields and my iPad completely ignoring my default email account is making it laborious to input my email address. Help!
    (Edit: I had a micro-brainwave and checked my "Me" card in Contacts, since I have Safari set to autofill from that card. My default email address is not listed first in the card. I've now put it on top, Gmail second and "me.com" last. I'll comment later on if I see this help with point 3 below.)
    Details:
    I love my shiny new iPad2. I really do. But autocorrect is driving me crrrrrazy when I try to input my email address.
    Typing in general is an issue for me, because I am disabled and have difficulties with coordination and movement. On my laptop (MacBook Pro mid 2009), I used TextExpander. It lets you set an abbreviation for any text, so you can just type that abbreviation instead of the whole thing, and TextExpander automagically inputs the whole thing for you.
    I have a long email address, because my ISP has quite a long domain name. So only typing 4 characters (my abbreviation) instead of the whole 23 characters was a big help for me.
    Enter the iPad.
    I need to use the iPad now, because my laptop is now too heavy for my legs (and I do occasionally need a full-on laptop, so the MacBook Air isn't the solution). The iPad in general has been great for me. The simplification of the interface (while annoying at times, e.g. not being able to view full headers in an email) saves brain cycles, so I can read for longer.
    However, where on my laptop I only needed to input 4 chars for my email address, on my iPad I have to input the whole 23 chars. How many places online are you asked to input your email address? Way too many. Safari may eventually catch up and record some of them, but currrently, I'm using too much of my day's energy just on trying to input my email address. (Note: this post is written on my laptop, so I can use my abbreviations.)
    TextExpander is available for iOS, but due to Apple's current refusal to allow integration with its apps, TextExpander isn't allowed to input stuff directly. Just like with the indispensable password program 1Password, you have to switch from Safari to the other app., search for and select and copy the text you want, then switch back to Safari, select the field and press Paste.
    Grrr.
    I may get desperate enough to go through those steps each time, if things don't improve with my email address. My problems are:
    1. Very few email-address fields in webpages currently have the appropriate settings to instruct the iPad keyboard not to start with the Shift key down. This means every time you try to input your email address, it will start with an upper-case letter.
    Half the time I don't notice until I've got part-way through typing my address, so I have to delete all those chars and start again. About a quarter of the time, after deleting, I don't notice that the Shift key has been activated again, so I go through the whole process again.
    2. Even when the email-address field turns off the Shift key, or when I remember to do it myself before entering text, autocorrect will insist on changing the first letter back to upper-case, because my username is also my first name. Cue more deleting and getting confused.
    3. This is the big one: once my username is up there, autocorrect insists on entering my "me.com" email address. This is the email address I use least. When I laboriously (again) delete this text and start again, it will either insist again on "me.com", or input my Gmail address. That is the email address I use second least. Autocorrect never inputs my main email address, set as my default account in the Mail-Con-Cal Settings. (This is a POP-only account.)
    4. Even if I do manage to input my whole email address correctly, autocorrect will insist on capitalizing the first letter of the domain name (which is also a location). Cue yet more deletion and retyping.
    Are there any ways to avoid wasting so much energy on trying to input my email address?
    Is there any way to set the default input email address? Or to tell the iPad/Safari that an email address field doesn't require the Shift key?
    I've had my iPad for nearly three months now, using it for my day-to-day activities, and I've been hoping this problem would gradually go away, that the software would finally catch on to my main email address (from the default account) which I have input over and over (and OVER) into email-address fields.
    Evidently not.
    Any ideas?
    Thanks in advance for any help you can offer.

    As Roosevelt suggested, you can turn off Auto Correction in the keyboard settings. Go to Settings>General>Keyboard>Auto Correction>Off.
    This will also turn off spell check (unfortunately) and there is no fix for that. Auto Caps can also be turned off as well and so can the keyboard shortcut for the space/period. Frankly, all of these features drive me nuts and I wish the iOS allowed for more control, but it does not.
    As fars as typing your email address, be aware that even if you type your email address in all caps it still works. So if Autofill insists on capitalizing the first letter in your name in the email address - and it will insist on doing so - you can just let it go as is and it will still work. Doesn't really get to the heart of the matter but it would save you the laborious deleting and retyping.
    Having said that, when the Auto Correction suggests a word or wants to set a capital latter, you can tap the "x" in the pop up suggestion to ignore that word, cap, whatever. The dictionary is then supposed to "learn" your word if you refuse that suggested word enough times. This is another feature that seems to have a mind of it's own at times since sometimes it may take more than a few attempts to get the Auto Correct to not come up and instead allow your chosen word to be freely typed as desired.
    Lastly, with regard to your correct email address popping up, that is another case of if repeated time and time again, It should be another case of the iOS "learning" through repetition that your default email should popup when you begin entering the address.
    You could try to rectify all of this by resetting all of your settings and clearing Autofill but you would be starting all over again which is something I think you would rather avoid.
    Settings>General>Reset>Reset All Settings
    Settings>General>Reset>Reset Keyboard Dictionary
    Settings>Safari>Autofill -tap names and passwords>Clear all
    As Roosevelt suggested, submit feedback, and I hope you find some resolution to this.
    Quick Note - I originally typed this post on my iPad and when I read a few of the words that were substituted by auto correct - I quickly turned to my iMac to change the words. I do feel your pain with regard to auto Correct!
    Message was edited by: Demo

  • Struts and ajax for input validation check

    Hi there
    I am not quite sure where I should post this question. I have a question about using ajax to check input valudation check on a jsp page which uses struts tab libs.
    For example, I want to check if input email has already existed in the database on the sign up page. If it is, a sameEmail jsp page will through out in the span area. Meanwhile, the form on this page should not be allowed to submit.
    Email test field
    <div><html:text property="email" onkeyup="showHint(this.value, 'hint', 'errors/sameEmail.jsp')"/><span id="hint"></span></div>There are two strateies in my mind
    Strategy 1. Disable the submit button when sameEmail.jsp is throwed out.
    I named all buttons operation in sign up page, so LookupDispatchAction page can process all the logical work depends on the value of these buttons. My questions is how I can disable signup submit button in javascript, as I need use this element id or name? Apperantly, I cannot add id into Strut 2 jsp page, plugs all buttons' names are the same on the sign up page.
    For example:
         <html:submit property="operation">
              <bean:message key="adminMainForm.signUpButtonLabel"/>
         </html:submit>
    <html:submit property="operation">
         <bean:message key="adminMainForm.deleteAll" />
         </html:submit> Strategy 2. Write something in the js page, which will block the data transfer.
    Something similar to
    function validateSignupInput(form) {
    if(form.customerEmail.value.exist()){
    return false;
    } Appearntly it doesn't work.
    My question is that how I can write this piece of js code.
    Any idea will be helpful, thank you.
    Ming

    Hi Karan,
    I did not get ur requirement but if the question deals with selection screens, I have an answer for it.
    before u do all these things, first you need to trigger an event called AT SELECTION-SCREEN.
    example code is :
    AT SELECTION-SCREEN.
        IF (fld name) > (value)   -
    > any logic which u need
               message
       endif.

  • How can I enable spell checking for a text box that is just one line, e.g. subject in e-mail?

    In a prior version of Firefox I found a website somewhere that told me what to do to enable spell checking for text boxes that are just one line. I got used to being able to send an e-mail with a Subject Line that didn't have a misspelling. Now it doesn't work. Please tell me how I can enable that again. I am on a Mac using Firefox 6.0.2. Thanks!

    See:
    *http://kb.mozillazine.org/Spell_checking
    *http://kb.mozillazine.org/layout.spellcheckDefault
    You can set the pref <b>layout.spellcheckDefault</b> to <i>2</i> on the <b>about:config</b> page.
    To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
    If you see a warning then you can confirm that you want to access that page.<br />
    *Use the Filter bar at to top of the about:config page to locate a preference more easily.
    *Preferences that have been modified show as bold (user set).
    *Preferences can be reset to the default or changed via the right-click context menu.

  • How do I have Firefox check for expired/revoked certificates?

    The Heartbeat vulnerability fix requires servers update openssl, get a new certificate, and revoke the old certificate. To be sure a spoofed site isn't using the revoked certificate, I need Firefox to check for revoked certificates. How do I turn this revoked certificate checking on in Firefox?

    hello eghuff, firefox should be set to check for revoked certificates by default, you can check that under ''firefox > options > advanced > certificates > validation''.

  • How to Disable InfoUpdate(spinf) check for PO creation

    Dear All,
    I got requirement to Disable InfoUpdate(SPINF) check when PO is created(ME21n).
    Long back for this Project our Team did some configuration(SPRO) for Order Type (Standard PO) this InfoUpdate(SPINF) should be checked by default.
    But know they don't want to create a PO with InfoUpdate(SPINF) check for ONE specific Plant(EKPO-WERKS).
    I tried to find User Exit and BAPI, But I not able to find the exact one to Disable InfoUpdate(SPINF) check based on the condition Plant(EKPO-WERKS).
    So, can some one give me solution to Disable InfoUpdate(SPINF) check.
    Thanks in advance.
    Regards,
    Venkat Ram

    Hi Guys,
    Any help? Any exits/BADIs/enhancement spots that I can use?

  • How to execute Se30(performance check) for a function module

    can anyone please let me know hot to execute perofrmance check for a function module.

    In SE30 below the program option you have Function Module option.
    Give the FM name there >execute, It will lead to the SE37 for Function Module execution screen, enter the values>Execute.
    The ctrl will return back to SE30.
    Press Evaluate to know the analysis.
    Hope this answers.
    Regards
    Vinayak

Maybe you are looking for