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

26
LINES

< > BotCompany Repo | #1035880 // MouseInComponentMonitor - variable that records whether mouse is hovering over component

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

Libraryless. Click here for Pure Java version (9670L/54K).

1  
sclass MouseInComponentMonitor extends BoolVarWithNotify is MouseListener, MouseMotionListener {
2  
  JComponent component;
3  
  settable bool verbose;
4  
  
5  
  *() {}
6  
  *(JComponent component) { init(component); }
7  
  
8  
  void init(JComponent component) {
9  
    if (this.component != null) fail("Already initialized");
10  
    this.component = component;
11  
    addMouseListener(component, this);
12  
    addMouseMotionListener(component, this);
13  
  }
14  
  
15  
  void print(S s) {
16  
    if (verbose) main print(s);
17  
  }
18  
  
19  
  public void mouseClicked(MouseEvent e) {}
20  
  public void mousePressed(MouseEvent e) {}
21  
  public void mouseReleased(MouseEvent e) {}
22  
  public void mouseEntered(MouseEvent e) { print("mouseEntered"); set(true); }
23  
  public void mouseExited(MouseEvent e) { print("mouseExited"); set(false); }
24  
  public void mouseMoved(MouseEvent e) { print("mouseMoved"); set(true); }
25  
  public void mouseDragged(MouseEvent e) { /*set(true);*/ }
26  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1035880
Snippet name: MouseInComponentMonitor - variable that records whether mouse is hovering over component
Eternal ID of this version: #1035880/9
Text MD5: 72a4efc135cd775822e30f8e70621a9e
Transpilation MD5: c62556880034b88422fd9e9143dcb673
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-06 20:07:44
Source code size: 938 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 166 / 240
Version history: 8 change(s)
Referenced in: [show references]