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

19
LINES

< > BotCompany Repo | #1005614 // onClick (any mouse button)

JavaX fragment (include)

static <A extends JComponent> A onClick(A c, IVF1<MouseEvent> runnable) {
  ret onClick(c, (O) runnable);
}

static <A extends JComponent> A onClick(A c, O runnable) {
  if (c != null) swing {
    c.addMouseListener(new MouseAdapter {
      public void mouseClicked(MouseEvent e) {
        callF(runnable, e);
      }
    });
  }
  ret c;
}

// re-interpreted for buttons
svoid onClick(JButton btn, O runnable) {
  onEnter(btn, runnable);
}

Author comment

Began life as a copy of #1003586

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005614
Snippet name: onClick (any mouse button)
Eternal ID of this version: #1005614/5
Text MD5: b9923cc4448265540eccac3c8ee66539
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-04 01:28:09
Source code size: 458 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 609 / 670
Version history: 4 change(s)
Referenced in: #1006598 - disposeFrameOnClick
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1006660 - onLeftClick
#1032088 - onClickDisposeWindow