Using two buttons market timer / stop, need help please.
Hey everybody.
I am stil working on my project, and now I'm trying to implement a timer using two buttons market / stop. Everything I do now is when you press start the stopwatch starts and when you press stop I want the timer to stop and display the time.
Whats happening is when I press start, the timer starts, but when stop is pressed the timer displays a value of say 12 seconds, a second more later I press stop again a value of 14secs arise and it stops at 14. Now, whenever I press on start it will start at 14 and repeat this process.
So I think that somewhere, I did not put my right timer.
Could someone say somethings that I should change in my code.
They are declared at the top:
static public boolean status=false; static public int count=0; static public Timer timer;
Here is my code:
ButtonField start = new ButtonField("Start",ButtonField.USE_ALL_WIDTH| ButtonField.FIELD_HCENTER|ButtonField.USE_ALL_HEIGHT); start.setChangeListener(new Listener1());add(start); ButtonField stop = new ButtonField("Stop",ButtonField.USE_ALL_WIDTH| ButtonField.FIELD_HCENTER|ButtonField.USE_ALL_HEIGHT); stop.setChangeListener(new Listener2()); add(stop); public class Listener2 implements FieldChangeListener { public void fieldChanged(Field field, int context) { ButtonField btn = (ButtonField) field; Status.show("Timer is at" + Integer.toString(count)); status = false; timer.cancel(); } } public class Listener1 implements FieldChangeListener { public void fieldChanged(Field field, int context) { ButtonField btn = (ButtonField) field; Status.show("Timer started"); status = true; try { timer = new Timer(); timer.scheduleAtFixedRate(new StartEvent(),1,1000); } catch(Exception e) { //do nothing } } private class StartEvent extends TimerTask { public void run() { if(status = true) { count++; } else timer.cancel();// count=0; } } }
any help is appreciated
Thank you guys
Probably best to follow just a matter of a Thread. So next time, you can start a new Thread with a new question. However, you should also search the forum before asking questions, that your two supplementary questions have been answered in other posts on this forum.
Concerning your problem to press the stop and get another moment, I think that you must have application logic that disables the stop button once pressed, until you press the Start button. For example, you could do by assigning to the time of departure - 1 in the Stop button, and then, when you press the Stop button, he can check the start time and displays a message saying "Timer not started" If the start time is - 1. There are a number of other ways to do this, I described this method because it is easy to explain. It is not really how I'd do.
The best way to set the buttons next, is to add then to a HorizontalFieldManager, then add the HorizontalFieldManager to your screen.
To stop the button displays the menu, you must set it with the style CONSUME_CLICK, for example:
ButtonField stopButton = new ButtonField ("Stop", ButtonField.CONSUME_CLICK);
Tags: BlackBerry Developers
Similar Questions
-
I used up to the allocation for the region 1 & 2 DVD for help. Stuck on region 1 now. I need to use the two regions for my DVD. Help, please. Beryl.
It isn't a MS solution, there are solutions to third parties not supported by MS
-
worked very well and when was time to save I get the cyclic redundancy check, I try several times and made the same thing I need help please
Hello Hans,.
Thanks for choosing Microsoft Community!
According to the description of the problem, you have problems when you use the backup on Windows 8 feature.
Please answer these questions to better understand the issue and help you:
1. are - what you're talking to backup and restore functionality on Windows 7?
2 have you made any changes to the computer before the show?
It is perhaps to cause bad sectors on the hard drive, run the disk check to repair bad sectors
Check your hard drive for errors:
http://Windows.Microsoft.com/en-us/Windows7/check-your-hard-disk-for-errors
Important: Running chkdsk on the drive if bad sectors are found on the disk hard when chkdsk attempts to repair this area if all available on which data can be lost.
For more information:
Backup and restore: frequently asked questions
http://Windows.Microsoft.com/en-us/Windows7/back-up-and-restore-frequently-asked-questions
Hope the helps of information. Don't answer if you need assistance, we will be happy to help you.
-
I need to change my apple user ID e-mail address. Since I will be withdrawn and used my personal E-mail address instead of company e-mail. I need help please on how to do it. I now use IPhone 6
Launch Safari on your iPhone, iPad or Mac and go to appleid.apple.com.
To an iOS device, tap on manage your Apple ID. If requested, please check your identity after the connection.
Click or tap on change in section Apple ID and primary e-mail address.
Edit with your new email address.
-
I have Windows XP 32-bit with IE8 Add ons. I mainly use Firefox Mozilla for my browser and Yahoo as my home page. Anyway, I have tried all the support and help guide and technicians told me to do to get add ons to open and activate but in vain. This computer was given to me as a profession, and it was used in a Bank, so I think that the system administrator has disabled the add ons. I myself as an administrator and use the tips and tricks given windows and Microsoft, but I always run up a wall. I need help, please.
I also need to know how to uninstall Windows antivirus software. I can't find anywhere on my computer. I feel really stupid and he is probably right in front of my face, but I can't find it to uninstall. I have McAfee that I paid dearly for if I want to use it until it expires.This "Microsoft antivirus' witness (AKA Trojan W32/FakeAlert) hijackware infection!
If you manage to somehow move to Win7, you will always have an infected computer.
The ONLY way to solve the problem is by formatting the current hard drive and do a clean installation of Windows, whether it is WinXP or Win7.
The ONLY way you can do a clean install of Windows XP if you have disks that came with the computer or if by chance, there is a hidden partition restore (not to be confused with the system restore).
If your kids er - well & their spouses are going to spend money on a new HARD drive, they'be be better spend on a low-end Windows 7 computer and brand-new (for example, a netbook or a mini).
NB: Any data on your Windows XP computer must be considered 100% reliable! (This includes all of your usernames and passwords, for example, those used for online banking, etc.) You do NOT want to put ALL the data from Windows XP to a new computer or HARD disk.
Good luck, Grandma. Hope that your grandchildren will treat you better than their parents.
PS: Time wounds all heels.
~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft
-
The guys that I need help please,
Last night I tried to install the update to alcapitan to my macbook pro, but it does not work it makes me a message (your installation cannot be finshed) and many many things and when I try to strt my macbook still keeps it install the updat and then get the message again...
I need help please
Hello, check if the mac you can use El Capitan. See the information update of OS X El Capitan - Apple Support here
-
Compaq cq10: need help please code error: CNU0015RN9 on compaq cq10 150ev
Need help please code error: CNU0015RN9
Thank you in advance!
Hello
No problem. Did you do a hard reset and try again?
For the error code, check again a time-
Try:
e9l11f3zv7
all lowercase letters
first letter is a small suitcase E
second is number Nine
third letter is small case L
fourth & fifth is number one
Sixth letter is small box F
seventh is number three
eighth letter is small suitcase Z
ninth letter is small case V
the last is number seven
Concerning
Visruth -
I want to return a plug-in, I accidentally deleted.i to play online snooker.can someone at - it need help please?
Hello
1. What plugin you are talking about?
2. on which site Web you are trying to play the game of billiards online?
3. what web browser do you use?
4. how exactly did you uninstall the plug?
Plug-ins are provided by third-party providers, you can try to load the game of billiards and verification that branch is needed.
Please come back with more information on the issue so that we can help you better.
You can also visit the link of the article of Microsoft that will guide you on how to ask questions below.
Suggestions for a question on the help forums
-
NEED HELP Please im having a problem to forget my password and when I plug it it says its locked with a password he tried to put the itunes thing but it says enter password I put in what I rember, then said lokced for five minutes help me pls
Without knowing the password for your iPhone, there is no way to unlock it, bring even you to the Genius Bar. If you continue to enter the wrong password, you will be locked out of your iPhone, and your data will be unaccessable.
-
I'm trying to upgrade my vista to the next operating system or even 10 if possible and I can do what I need help please
Hello
There is no free upgrade Vista to 7, 8.1, or 10.
Follow these steps before you buy Windows 7.
Microsoft sells more than 7; Try Amazon.com.
Go to your computer / computer laptop manufacturer Web site and see if Windows 7 drivers are available for your make and model computer / laptop.
If this is not available, Windows 7 will not properly work for you.
Run the "Windows 7 Upgrade Advisor.
http://www.Microsoft.com/en-US/Download/details.aspx?ID=20
Check if your specifications are compatible for Windows 7:
"Windows 7 system requirements"
http://Windows.Microsoft.com/en-us/Windows7/products/system-requirements
"Windows 7 Compatibility Center" for software and hardware:
http://www.Microsoft.com/Windows/compatibility/Windows-7/en-us/default.aspx
Windows 7 upgrade paths:
http://TechNet.Microsoft.com/en-us/library/dd772579 (v = ws.10) .aspx
«Installation and reinstallation of Windows 7»
http://Windows.Microsoft.com/en-us/Windows7/installing-and-reinstalling-Windows-7
@@@@@@@@@@@@@@@@@@@@@@@@
Follow these steps before buy you and upgrade (new installation) of Windows 8.1.
Check if the manufacturer of your computer/laptop has Windows 8.1 drivers available for your model.
If this is not available, Windows 8.1 not install and work properly for you.
There is a lot of information in this first link from Microsoft:
Download and run the Windows Upgrade Assistant 8.1 of to see if your machine is compatible Windows 8.1 and read the update for Windows 8.1: FAQ here
"Update to Windows 8.1: FAQ".
http://Windows.Microsoft.com/en-us/Windows-8/upgrade-to-Windows-8
"8.1 for Windows system requirements.
http://Windows.Microsoft.com/en-us/Windows-8/system-requirements
@@@@@@@@@@@@@@@@@@@@@@@
How to buy Windows 10:
http://www.microsoftstore.com/store/msusa/en_US/cat/Windows/CategoryID.70036700
But first make sure that you have the correct configuration and your computer manufacturer provides the right drivers for 10.
https://www.Microsoft.com/en-us/Windows/Windows-10-specifications#sysreqs
" System requirements Windows 10"
https://www.Thurrott.com/Windows/Windows-10/3884/Windows-10-system-requirements
Microsoft deploys Windows 10 available as free upgrade to Windows 7 features, Windows and Windows Phone 8.1 8.1 qualified. It will be available from July 29, 2015
"FAQ Windows 10.
http://www.Microsoft.com/en-us/Windows/Windows-10-FAQ
See you soon.
-
I have the table of 3 columns A, B, C. I want to store the sum of columns A B in the C column without using the DML statements. Can anyone help please how to do. ?
11.1 and especially you have virtual column
SQL> create table t 2 ( 3 a number 4 , b number 5 , c generated always as (a+b) virtual 6 ); Table created. SQL> insert into t (a, b) values (1, 2); 1 row created. SQL> select * from t; A B C ---------- ---------- ---------- 1 2 3
Before that, a front insert - trigger
SQL> create table t 2 ( 3 a number 4 , b number 5 , c number 6 ); Table created. SQL> create or replace trigger t_default before insert on t for each row 2 begin 3 :new.c := :new.a+:new.b; 4 end; 5 / Trigger created. SQL> insert into t (a, b) values (1, 2); 1 row created. SQL> select * from t; A B C ---------- ---------- ---------- 1 2 3
-
Hello. I warned to creative cloud, but not what I was looking for. I want to cancel, but I can't find where I can do. I need help please. Thank you
Hello
Please see: -.
In order to cancel the order, please contact customer service
You can check: http://helpx.adobe.com/x-productkb/global/phone-support-orders.html
For more information on cancellation: cancel your creative cloud membership
-
See tittle for the description of the problem. Why can you give us a service pack that some many people have trouble installing? Its stupid. Wasted my time and yours. Please help with this and post the fix so that others don't have to go through this same process.
Thank youJeffHello Wookie312,
Thanks for your post. Please follow the troubleshooting steps below and let us know the results of each utility.
1. download / install and run the tool update system - CheckSur. You can download the tool from the link below.
Download the tool update system (64-bit)
2. click Start type cmd (you should see the command prompt fill up) right click and select run as administrator
Inside the command prompt, type sfc/scannow
For more information regarding the file system checker.
* If corruption is found, see How to use the System File Checker tool to fix the system files missing or corrupted on Windows Vista or Windows 7
3. once the SFC is finished, check your hard drive for errors.
4 restart the system update readiness tool. If errors have been eliminated, try to reinstall Service Pack 1. If this is not the case, go to step 5.
5. perform a Startup Repair, when starting, try to install the Service Pack.
We can't wait to hear back on your part.
See you soon
-
try to set up my microsoft email in my pc. I need to respond to the need help sbout incomeing craiglist.i and out going.
I have no idea to find my server address. I use connect netgear wireless.
Hello
Looks like you need configure Windows Mail
you need to configure your e-mail account windows mail with your ISP internet service provider
They provide you with account settings you need to do
Ask them to
username
password for your access broadband account / distance with themServer of incoming POP3 mail
outgoing mail SMTP serverand here's how to configure windows mail after getting the email correct account settings
-
Who's using Muse and Shopify? I need help
I need help with the insertion of buy now buttons and cart loaded on my site I created with Muse
You can check the options available here:
http://resources.Muse.Adobe.com/collections/widgets/ecommerce
Thank you
Sanjit
Maybe you are looking for
-
Have a 2008 17 MBP, now with 1 TB SSD. It heats up and I am deaf so need a fan ap to see his work. Last rev of El Capitan works well. What ap to get? Thank you! JIm in Chicago
-
Name of the failing application: Skype.exe, version: 7.0.0.102, time stamp: 0x54897addName of the failed module: Skype.exe, version: 7.0.0.102, time stamp: 0x54897addException code: 0xc0000005Offset: 0x00d527d7ID of the process failed: 0 x 1744Start
-
Why a trail shaded in an album of my friends?
Why a track appears dimmed in an album of my friends, and what that means? iTunes can play the track if you click on it, but if it comes after another track iTunes jump it! I have the latest version of iTunes.
-
Hello I want to ask this; What happens if someone steals my iphone / backup file of the ipad to my itunes or something like that. What can do with my backup of the device? I can nothing detected when it is?
-
All three 5DrS crop factors performance 60 MB + trust
It would seem reasonable that when you choose to create an image cropped on the 5Drs, the smaller stage should still fill the viewfinder to produce a good view of the subject. It should also that a cropped image would result in a smaller file when