daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Jul 12th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ToggleButton myToggle = new ToggleButton();
  2.  
  3. Timer myTimer = new Timer() {
  4.   @Override
  5.   public void run() {
  6.     if (myToggle.isDown()) {
  7.       // Perform repeating action.
  8.     } else {
  9.       cancel();
  10.     }
  11.   }
  12. };
  13.  
  14. myToggle.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
  15.   @Override
  16.   public void onValueChange(ValueChangeEvent<Boolean> event) {
  17.     if (event.getValue().booleanValue() == true) {
  18.       // Perform the repeating action twice/second.
  19.       myTimer.scheduleRepeating(500);
  20.     }
  21.   }
  22. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top