aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes IP address in JFormattedTextField Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "IP address in JFormattedTextField" Watch "IP address in JFormattedTextField" New topic
Author

IP address in JFormattedTextField

Tahir Abbas
Ranch Hand

Joined: May 05, 2007
Posts: 45
Hi to everyone,

I'm trying to get the IP address in JTextField like 127.0.0.1 (for client to connect Server). I used new MaskFormatter("###.###.###.###") but it doesn't work properly in many cases. Do i need to write some code to get proper input or you guys can tell any better solution.

I'm also considering of taking input in 4 text boxes but i'll wait for your valueable suggestions.

Thanks! in advance
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Howdy, Tahir!

Champion, in my case, here's what I did: I simply provided a JTextField for the user to provide the server's IP address (and the user can provide really anything). Before trying to connect, I verify if the user provided a valid IP address (by using regular expression); if so, then the client tries to connect to the server, otherwise, a message box, saying that the provided IP address is invalid, is displayed.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2627
    
    9

You may want to check this out http://www.coderanch.com/t/437296/Beginning-Java/java/IP-address-regular-expression


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5608
    
  15

Hi Tahir,

You could also take a look at this thread.

Good luck!
Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IP address in JFormattedTextField