943,735 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 840
  • Java RSS
Nov 5th, 2008
0

Java Time

Expand Post »
Hello everyone. I wanted to know how I could create a simple time restriction variable. For example making private double hour; not go over 2:59. Basically I don't want someone to be able to input a number greater than :59 in a Jtextfield. I can do a time application, but that takes a while. I just want to find a simple way of doing it. Thanks in advance. This is what the program is suppose to do below. I've already done everything except getting the time to have a restriction.

A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24 hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write an applet that calculates and displays the parking charges for each customer who parked in the garage yesterday. You chould enter in a JTextField the hours parked for each customer. The applet should display the charge for the current customer and should calculate and display the running total of yesterday's receipts. The applet shoud use the method calculateCharges to determine the charge for each customer.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
NycNessyness is offline Offline
58 posts
since Aug 2007
Nov 5th, 2008
0

Re: Java Time

You could restrict the length of the text field to to chars. Then you could set up a listener event to validate the text field when it looses focus or when they try to submit the form. I can't think of a way to validate the JTextField other than that
Reputation Points: 10
Solved Threads: 6
Newbie Poster
bionicseraph is offline Offline
19 posts
since Nov 2008
Nov 6th, 2008
0

Re: Java Time

Try Googling "validating JTextField."

First result was your question covered in depth: http://java.sun.com/developer/JDCTec...01/tt1120.html
Last edited by destin; Nov 6th, 2008 at 12:28 am.
Reputation Points: 32
Solved Threads: 10
Junior Poster in Training
destin is offline Offline
94 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Store the speech content
Next Thread in Java Forum Timeline: signed Applet





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC