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).

sclass MouseInComponentMonitor extends BoolVarWithNotify is MouseListener, MouseMotionListener {
  JComponent component;
  settable bool verbose;
  
  *() {}
  *(JComponent component) { init(component); }
  
  void init(JComponent component) {
    if (this.component != null) fail("Already initialized");
    this.component = component;
    addMouseListener(component, this);
    addMouseMotionListener(component, this);
  }
  
  void print(S s) {
    if (verbose) main print(s);
  }
  
  public void mouseClicked(MouseEvent e) {}
  public void mousePressed(MouseEvent e) {}
  public void mouseReleased(MouseEvent e) {}
  public void mouseEntered(MouseEvent e) { print("mouseEntered"); set(true); }
  public void mouseExited(MouseEvent e) { print("mouseExited"); set(false); }
  public void mouseMoved(MouseEvent e) { print("mouseMoved"); set(true); }
  public void mouseDragged(MouseEvent e) { /*set(true);*/ }
}

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: 165 / 238
Version history: 8 change(s)
Referenced in: [show references]