sclass CustomToolTip { JComponent target; JWindow window; bool debug; swappable JComponent makeContent() { null; } *(IF0 *makeContent) {} // run in Swing thread void move { if (window == null) ret; if (debug) print("CustomToolTip move"); var mouse = mouseLocationOnScreen(); window.setLocation(mouse.x+10, mouse.y+10); } // run in Swing thread void showOrMove { if (window != null) ret with move(); window = new JWindow; window.pack(); thread "Make tool tip content" { var content = makeContent(); if (content == null) ret; swing { setWindowContents(window, content); move(); window.pack(); showWindow(window); } } } void hide swing { disposeWindow(window); window = null; } void installOn(JComponent target) { this.target = target; addMouseAdapter(target, new MouseAdapter { @Override public void mouseEntered(MouseEvent e) { showOrMove(); } @Override public void mouseExited(MouseEvent e) { hide(); } @Override public void mouseMoved(MouseEvent e) { showOrMove(); } @Override public void mousePressed(MouseEvent e) { hide(); } }); } }