Is there an elegant way in Swing to find out if there are tooltips displayed in my frame?
I use my own tooltips, so it would be very easy to set a flag in my method createToolTip(), but I don’t see a way to find out when the tooltip disappeared.
ToolTipManagerhas a good flag for this, tipShowing, but of course it is private, and they don't seem to offer a way to get to it. hideWindow()does not call the tooltip component (what can I say), so I do not see the way there.
Anyone have any good ideas?
Update: I went with reflection. You can see the code here:
private boolean isToolTipVisible() {
ToolTipManager ttManager = ToolTipManager.sharedInstance();
try {
Field f = ttManager.getClass().getDeclaredField("tipShowing");
f.setAccessible(true);
boolean tipShowing = f.getBoolean(ttManager);
return tipShowing;
} catch (Exception e) {
return false;
}
}