Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

textbox field validation in gui

 
David Winters Junior
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a query regarding how we can handle the situation whereby the user chooses an invalid db file , enters an invalid port number or tries to start the rmi server and leaving the database location and/or port field blank.

In my current design the user should enter these values in the Ui and click on the 'start' button in the gui to start the rmi server however just wondering how others have dealt with the sitation when the user enters invalid or no values for the database location field and/or port number. Do you display an error dialog to the user and allow him/her to re-enter these values in a seperate or the same window.

I would like to display a dialog message with the user message and then return to the original frame in which the textfields/ buttons resides so that the user can re-enter however i am not sure how to accomplish this.. is it possible in any way to allow for this.. so that normal program execution is suspended until teh user re-enters valid values and retires to start the server.

Any help/thoughts would be appreciated

thanks,
david
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, partner.
I created a port number validator and an IP address validator too. They are 2 components For the server initialization, I provide 2 text fields, where the user enters the db location and the port number. You need to put these verifications inside the actionPerformed method of your ActionListener. Then you add this ActionListener to your "Start" button.
The idea of your ActionListener can be something like this:



Please take a look at the ActionListener interface and the JOptionPane class. I believe this is what you are looking for.
 
David Winters Junior
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks alot for the reply and your suggestions.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic