Java Time

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2007
Posts: 58
Reputation: NycNessyness is an unknown quantity at this point 
Solved Threads: 0
NycNessyness NycNessyness is offline Offline
Junior Poster in Training

Java Time

 
0
  #1
Nov 5th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 19
Reputation: bionicseraph is an unknown quantity at this point 
Solved Threads: 6
bionicseraph bionicseraph is offline Offline
Newbie Poster

Re: Java Time

 
0
  #2
Nov 5th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 94
Reputation: destin is an unknown quantity at this point 
Solved Threads: 10
destin's Avatar
destin destin is offline Offline
Junior Poster in Training

Re: Java Time

 
0
  #3
Nov 6th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC