• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Swim Timer

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my dad wants me to make a timer (similar to a bleep test) to help him with his swimming lessons basicly it counts down from 20 bleeps then counts down from 19 bleeps,18 bleeps and so on so far ive got this


i think the problem lies in the for loop i can't quite get them and also will this run on windows mobile.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"george93",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with display names get deleted, often without warning

thanks,
Dave
 
George Payne
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'd just like to add some more information, Sorry i couldn't find the edit button. The code itself runs ok its just when i press the button that it starts to crash I think it goes into a stage of permanent loop. Also the pocket pc i plan to run it on is an acer n35.
 
George Payne
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'd just like to add some more information, Sorry i couldn't find the edit button. The code itself runs ok its just when i press the button that it starts to crash I think it goes into a stage of permanent loop. Also the pocket pc i plan to run it on is an acer n35. I think with an MIP5 proccesor
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi George!

To begin with the most important the edit butten is in the line where it says "posted November...", the pen and paper icon:


Your code has two things to be improved, one is easy:
in your action performed method it says:
time.setText("i");

in the i-loop.


The code does not crash - it only lasts 20 secs (minimum) until the frame displays a giant "i".


After you fixed that, you again will wait for 20 secs to see a giant "1" then.

The frame will not be updated just be setting the text to a different number. The loop loops, but the numbers in between are not displayed. Using repaint() doesn't help.

More difficult part:
You will need to put this Timer-loop into an own thread.

There is also something strange with the layout, normally you add a panel to a frame and the button and label to the panel.


How did Dory sing?

"Keep on swimming, keep on swimming, keep on swimming, swimming, swimming...".
Yours,
Bu.
[ November 04, 2006: Message edited by: Burkhard Hassel ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic