Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

49
LINES

< > BotCompany Repo | #1000877 // installTimer (AWT timer)

JavaX fragment (include)

import javax.swing.event.AncestorListener;
import javax.swing.event.AncestorEvent;
import javax.swing.Timer;

// first delay = delay
static Timer installTimer(JComponent component, O r, long delay) {
  ret installTimer(component, r, delay, delay);
}

// first delay = delay
static Timer installTimer(RootPaneContainer frame, long delay, O r) {
  ret installTimer(frame.getRootPane(), r, delay, delay);
}

// first delay = delay
static Timer installTimer(JComponent component, long delay, O r) {
  ret installTimer(component, r, delay, delay);
}

static Timer installTimer(JComponent component, long delay, long firstDelay, O r) {
  ret installTimer(component, r, delay, firstDelay);
}

static Timer installTimer(final JComponent component, final O r, final long delay, final long firstDelay) {
  ret installTimer(component, r, delay, firstDelay, true);
}

static Timer installTimer(final JComponent component, final O r, final long delay, final long firstDelay, final bool repeats) {
  if (component == null) null;
  ret (Timer) swingAndWait(func {
    final new Var<Timer> timer;
    timer.set(new Timer(toInt(delay), actionListener {
      temp tempActivity(r);
      pcall {
        if (!allPaused())
          if (isFalse(callF(r)))
            cancelTimer(timer!);
      }
    }));
    timer->setInitialDelay(toInt(firstDelay));
    timer->setRepeats(repeats);
    bindTimerToComponent(timer!, component);
    ret timer!;
  });
}

static Timer installTimer(RootPaneContainer frame, long delay, long firstDelay, O r) {
  ret installTimer(frame.getRootPane(), delay, firstDelay, r);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000877
Snippet name: installTimer (AWT timer)
Eternal ID of this version: #1000877/8
Text MD5: 3e05e5ae560371225c36a9a72d13998a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-07 14:57:25
Source code size: 1637 bytes / 49 lines
Pitched / IR pitched: No / No
Views / Downloads: 883 / 1455
Version history: 7 change(s)
Referenced in: [show references]