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

13
LINES

< > TinyBrain | #1009857 - cancelTimer - cancel javax.swing.Timer or java.util.Timer - also takes AutoCloseable

JavaX fragment (include)

static void cancelTimer(javax.swing.Timer timer) {
  if (timer != null) timer.stop();
}

static void cancelTimer(java.util.Timer timer) {
  if (timer != null) timer.cancel();
}

static void cancelTimer(O o) {
  if (o instanceof java.util.Timer) cancelTimer((java.util.Timer) o);
  else if (o instanceof javax.swing.Timer) cancelTimer((javax.swing.Timer) o);
  else if (o instanceof AutoCloseable) pcall { ((AutoCloseable) o).close(); }
}

download  show line numbers  debug dex   

Travelled to 6 computer(s): cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1009857
Snippet name: cancelTimer - cancel javax.swing.Timer or java.util.Timer - also takes AutoCloseable
Eternal ID of this version: #1009857/7
Text MD5: 44bf424a0723c6586d1c43f06bfe208b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-07 22:09:34
Source code size: 449 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 77 / 100
Version history: 6 change(s)
Referenced in: [show]