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

16
LINES

< > BotCompany Repo | #1018604 // onMouseDown (left button only)

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

Libraryless. Click here for Pure Java version (4736L/26K).

1  
static MouseAdapter onMouseDown(Component c, Runnable r) {
2  
  ret onMouseDown(c, runnableToIVF1(r));
3  
}
4  
5  
static MouseAdapter onMouseDown(Component c, IVF1<MouseEvent> f) {
6  
  ret c == null || f == null ?: swing(-> {
7  
    MouseAdapter ma = new {
8  
      public void mousePressed(MouseEvent e) {
9  
        if (e.getButton() == MouseEvent.BUTTON1)
10  
          f.get(e);
11  
      }
12  
    };
13  
    c.addMouseListener(ma);
14  
    ret ma;
15  
  });
16  
}

Author comment

Began life as a copy of #1015170

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018604
Snippet name: onMouseDown (left button only)
Eternal ID of this version: #1018604/7
Text MD5: b067075d5a3daaf53328143c0517aa84
Transpilation MD5: 710f7b3c346127676accab9214e0779f
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-25 18:16:38
Source code size: 434 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 342 / 436
Version history: 6 change(s)
Referenced in: [show references]