Skip to content

Commit 45e2943

Browse files
hansonrhansonr
authored andcommitted
smooths tooltip presentation when it is rapidly changing
1 parent 7ab5c49 commit 45e2943

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

sources/net.sf.j2s.java.core/src/javax/swing/ToolTipManager.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
import java.awt.event.MouseMotionAdapter;
5353
import java.awt.event.MouseMotionListener;
5454

55+
import javajs.api.JSFunction;
56+
import swingjs.JSToolkit;
57+
5558
/**
5659
* Manages all the <code>ToolTips</code> in the system.
5760
* <p>
@@ -375,22 +378,23 @@ void showTipWindow() {
375378
insideTimer.start();
376379
tipShowing = true;
377380
}
378-
// System.out.println("TTM showTipWindow2");
379381
}
380382

381383
void hideTipWindow() {
382384
if (tipWindow != null) {
383-
// System.out.println("TTM hideTipWindow1");
384385
if (window != null) {
385386
window.removeMouseListener(this);
386387
window = null;
387388
}
388-
tipWindow.hide();
389+
@SuppressWarnings("unused")
390+
Popup win = this.tipWindow;
391+
// give this a few milliseconds, for continuity
392+
JSToolkit.dispatch(/** @j2sNative function() {win.hide$()} || */null, 10, 0);
393+
// tipWindow.hide();
389394
tipWindow = null;
390395
tipShowing = false;
391396
tip = null;
392397
insideTimer.stop();
393-
// System.out.println("TTM hideTipWindow2");
394398
enterTimer.stop();
395399
exitTimer.stop();
396400
}
@@ -645,6 +649,14 @@ private void checkForTipChange(MouseEvent event) {
645649
mouseEvent = event;
646650
if ((newText == null || newText.equals(toolTipText))
647651
&& (newPreferredLocation == null || newPreferredLocation.equals(preferredLocation))) {
652+
653+
654+
if (newText != null) {
655+
enterTimer.restart();
656+
return;
657+
}
658+
659+
648660
// if (tipWindow != null) {
649661
// System.out.println("restarting insideTimer");
650662
// insideTimer.restart();

0 commit comments

Comments
 (0)