• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Customer number check

 
Jonathan Pengelly
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am using the JOptionPane class to get the user to input the customer number when they want to book a contractor. The customer number must be either null or an 8 digit number.
I was considering using a formatted text field or document or something like that but instead I am currently reading the text from an input dialog and then checking the text with a regular expression (using the String.matches method).
I think that this seems pretty good however it sounds like most people have used a Document or format mask. What does everybody think?
Regards,
Jonathan
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what most people did. I wrote myself a simple dialog framework that I reused for all my dialog boxes in my application. I considered using JOptions, but decided against it since I didn't like the possibilities it left me for validation.
I just used a simple JTextField, reading in the string, making sure that it could be parsed to a numeric value (spec requirement), and that the actual string entered was the correct length (spec requirement) -- so trailing 0s were accounted for in the validation. (I had URLyBird.)
Hope that helps you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic