Forums Register Login

applet not working..... and I can't figure out why

+Pie Number of slices to send: Send
I've worked on this code for 2 days and I'm not sure why this applet won't run correctly. It's supposed to accept a parameter called Times which would have time values separated by the | symbol .... 10:15|14:20|8:30 ... and so on. Then it's supposed to create an alarm object for each time and the alarm object is supposed to go off and write to the screen whenever that time has been reached or exceeded. I'm pretty new to writing applets and java in general, so I'm not sure where I'm going wrong. It compiles fine with no errors, but it just won't sound the alarm or write to the screen when the time has been reached. Thanks.

[ June 04, 2002: Message edited by: tyler jones ]
+Pie Number of slices to send: Send
Hi Tyler,
Just a few things to help you out. You are using the Calendar functions incorrectly. You are not getting the correct day, month, or year. You should do the following:

The other problem that I can see is that you need to loop in your run method to keep checking the time. Otherwise you will only check once and your done! You also have your comparison backwards. What you want:

I am not sure what you are trying to do by having your AlarmClock extend Applet ... I would just have it pop up a Dialog or something when the alarm is hit and forget trying to have 2 applets.
Regards,
Manfred.
+Pie Number of slices to send: Send
I agree, I would suggest you have a "pop" window for the the alarm. But anyway, I also agree you are only checking the time once in the AlarmClock in the run method and once you exit the method at the point the thread is dead.
craig
+Pie Number of slices to send: Send
Thanks for your input and suggestions. I really appreciate it. As for why I'm extending Applet, I was doing that because the applet class provided me with the audioclip class so I can play an alarm sound. I wasn't aware of another way to be able to get the audioclip class without extending applet. I don't understand why you added 1 to the month though that is being returned by the calendar. I didn't see in Sun's documentation that the call to get the month returned the previous month. Is this the case or is there something else going on that I don't see? Thanks.
+Pie Number of slices to send: Send
Hi Tyler,
The Calendar MONTH value is zero based. Therefore the month of June will be 5. When you use the 5 in your SimpleDateFormat it will be the wrong month. Therefore you will need to add 1 to the value to get the correct date out of your SimpleDateFormat method call.
Regards,
Manfred.
You may have just won ten million dollars! Or, maybe a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1119 times.
Similar Threads
why won't my pop up window close?
problem with classes
Phasor applet-some prbs already compiled code written here
UnsatisifedLinkError exception. why am I getting this?
Stopping a looping javax.sound.sampled audio clip
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:42:11.