Could you please tell me how I can test if a value is below some threshold during 1 minute in java ?
e.g value = 50. if value<20 more than 1 minutes do ….
Thanks.
Abs
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You tagged this question swing therefore I suppose that this value is set in a
JComponentsuch as aJTextField.In such a case, the easiest approach would be attaching the appropriate listener (let’s call it ‘L’) to that
JComponent. For a JTextField, you could use a KeyListenerWhen your component’s value is updated, ‘L’ will be invoked and:
– if the new value is < 20, you trigger a one minute Timer that will execute your action. Let’s call that timer ‘T’
– otherwise, if ‘T’ was running, you cancel it.