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

23
LINES

< > BotCompany Repo | #1032114 // addAWTEventListener_inFront - add global AWT listener in front of all others

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3655L/20K).

svoid addAWTEventListener_inFront(AWTEventListener listener, long eventMask) {
  if (listener == null) ret;
  swing {
    var tk = awtToolkit();
    EventListener[] otherListeners = tk.getAWTEventListeners();
    
    new LPair<AWTEventListener, Long> listenersWithMask;
    
    fOr (var l : otherListeners)
      if (l cast AWTEventListenerProxy) {
        listenersWithMask.add(pair(l.getListener(), l.getEventMask()));
      } else {
        warn("Can't get event listener mask: " + l);
        ret;
      }

    fOr (var l : listenersWithMask)
      tk.removeAWTEventListener(l.a);
    tk.addAWTEventListener(listener, eventMask);
    fOr (var l : listenersWithMask)
      tk.addAWTEventListener(l.a, l.b);
  }
}

Author comment

Began life as a copy of #1032112

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032114
Snippet name: addAWTEventListener_inFront - add global AWT listener in front of all others
Eternal ID of this version: #1032114/7
Text MD5: dc6ce73fde2728a3ac87fbb0d47dd629
Transpilation MD5: 9cd555aaa467e520f0b6c89c444bbe07
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-14 00:37:57
Source code size: 739 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 170 / 253
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)