Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TextField validating for IPAddress

 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I'm having a JMaskedTextField that accepts IPAddress, Now the problem is I need to set the IPAddress limits to 255.255.255.255 as max and also, if the user inputs 011.11.11.11, it takes it as
011.11_.11_.11_ How do I solve this problem ?!!Please help me with this confusion. Is there a swing component or an AWT component that accepts and sets the limits for this purpose and format ?!
Thanks
Meghna
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm. One thing you might want to look at is using the INetAddress class. What I am thinking is that if you passed the text that the user enters to create one of these Network classes, maybe not INetAddress, but like Socket. You put this inside a try/catch statement, and if it catches an Exception, then the IP Address the user typed into the field is invalid.
Now this might not directly answer your question, but might send you down a different path, one that might be acceptable, or one that will get to the right answer later.
Hope this helps
Mark Spritzler
 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark
Do I have to write the INetAddress class separately or is it available already. Please let me know the details so that I can find out if I can go through with the soln. In the meanwhile, if you come across somethign please let me know.
Thanks
Meghna
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
INetAddress is a java class that is part of the java.net package.
It comes with the JDK.
http://java.sun.com/j2se/1.3/docs/api/index.html
click on the class on the bottom left frame. It will give you the documentation for this class
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic