• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IP address in JFormattedTextField

 
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: 2271
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: 3583
16
Android Java
 
Roel De Nijs
Sheriff
Posts: 10662
144
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