Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

IP address in JFormattedTextField  RSS feed

 
Tahir Abbas
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2273
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to check this out http://www.coderanch.com/t/437296/Beginning-Java/java/IP-address-regular-expression
 
Roel De Nijs
Sheriff
Posts: 11200
174
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tahir,

You could also take a look at this thread.

Good luck!
Kind regards,
Roel
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!