Re: Formatting a JTextField to only allow ip addresses?

From: Steve W. Jackson (stevewjackson_at_charter.net)
Date: 01/27/05

  • Next message: Florence HENRY: "Re: GridLayout and glue"
    Date: Thu, 27 Jan 2005 10:37:45 -0600
    
    

    In article <4m0Kd.153964$KO5.74217@clgrps13>,
     "Ken Adams" <hockeyGuy17@hotmail.com> wrote:

    >:Anybody know of a free custom swing component that represents an IP address.
    >:Or does anybody know how to format a JTextField to only allow ip addresses.
    >:So basically I want to keep it in the form 192.168.1.101.
    >:
    >:Any suggestions
    >:
    >:Thanks

    Personally, I would suggest using four fields instead of one, where each
    individual field can contain values ranging from 000 to 255 and perhaps
    typing the third digit could even auto-tab out to the next field.

    It would be far easier to write a single JTextField subclass that
    accepts only numeric input and only a max set of digits, etc. You can
    easily display these in such a way that the dots appear between them on
    other components. And with a little experimentation, you might even be
    able to set up other restrictions if needed, like not allowing 000 in
    certain octets.

    = Steve =

    -- 
    Steve W. Jackson
    Montgomery, Alabama
    

  • Next message: Florence HENRY: "Re: GridLayout and glue"