Timer placed on form??

I want to place Timer on one of my solution form.
Any buddy have any Idea…?? How can make it Possible.??

Thank you

Hi prem,

You can use the IClock bean that comes bundled with Servoy.
Just check the properties to change it’s appearance and function. You can use it to show the current time but (if I am not mistaken) also to use as a stopwatch.

Hope this helps.

Hi,
Robert.
That was quck reply. Thank You… :D

I have struggled with this bean also, but I never succeeded into making it a stopwatch. If anyone did, I like to now some tips, how to achive this.

HI
Bean is working on my form. I m also not able to create stop watch.

Good question!
The functions start and stop are of course very obvious but doesn’t make it not change back to the current time.
I bet the answer lies in the use of the functions removePropertyChangeListener(String, PropertyChangeListener) and/or propertyChange(PropertyChangeEvent).

Anyone knows what these params should be ?

prem:
I want to place Timer on one of my solution form.
Any buddy have any Idea…?? How can make it Possible.??

Thank you

Do you need a visual timer? Or just something to time things? With one global you can time things: set new Date() to it when the user clicks on start and substract the currend dateime from it when he clicks on stop.

Hi Jan, this is what we have now, but we would like to have stopwatch ‘LIVE’ on the screen.

HJK:
Hi Jan, this is what we have now, but we would like to have stopwatch ‘LIVE’ on the screen.

Sounds like a great javabean project. Marcel? Patrick?

I will have a look. Shouldn’t be so difficult. Maybe somebody finds a good starting point?

Hi,
Thanx jan,
We r looking for StopWatch. StopWatch would be useful tool.

Start method:

elements.bn_clock.stop()

var time = elements.bn_clock.time

time.setHour(0)
time.setMinute(0)
time.setSecond(0)

elements.bn_clock.time = time

elements.bn_clock.start()

Stop method:

elements.bn_clock.stop()

var stopTime = elements.bn_clock.time

application.output((stopTime.getHour() * 3600) + (stopTime.getMinute() * 60) + stopTime.getSecond())

David to the rescue! :D

That works perfectly. Thanks David.
One remark though. You better get the time right after the stop (or even before) because the timer seems to continue even after the stop function.
Seems this is a ‘stop painting the time’ function instead of really stopping the timer.

Hope this helps.

david:
Start method:

snip
Stop method:

Great, David: thanks a lot… :D

Here’s an oddball idea: since beans run in their own thread, this could be a cheap man’s way to show a user feedback during long methods. Eh, YMMV…

//start time
elements.bn_clock.stop()
var time = elements.bn_clock.time

time.setHour(0)
time.setMinute(0)
time.setSecond(0)

elements.bn_clock.time = time
elements.bn_clock.start()
elements.bn_clock.visible = true


//your method code here
application.sleep(5001)


//stop clock
elements.bn_clock.stop()
var stopTime = elements.bn_clock.time
elements.bn_clock.visible = false

application.output(stopTime.getSecond())

Thank you David.

This is Working perfectly. This is gr8. :D

hi,
ALL. Now i have one more problem. This Code Working well in smart client . I want same functionality in Web Client. How can I make It Possible.

Thank You

I don’t think this is possible right now…

prem:
hi,
ALL. Now i have one more problem. This Code Working well in smart client . I want same functionality in Web Client. How can I make It Possible.

Thank You

Web client offers different possibilities. I would look for a web service/widget that offers a stopwatch and integrate it using an html_area field. The google maps demo is a great example of this technique:

http://www.servoymagazine.com/home/2007/02/article_integra.html

If you want to use a clock/stopwatch in your webclient then you need to do that with client-side scripting. I.e. a javascript running inside the browser, NOT in the webclient on the server.
You could indeed check the source of some widgets or you can google for it.
A quick google search for ‘javascript stopwatch’ came up with this for instance:
http://proft.50megs.com/stopwatch.html

Hope this helps.