问题
Eclipse has these highly interactive tooltips that appear when you hover over variables while debugging. You can actually click on the inside of these tooltips (or press F2) to focus and start interacting with the controls inside of it (specifically to explore that variable's object and its contents).
I really want to know if the library for this interactive ToolTip is accessible so I can use it for my own project. I like how it acts like a ToolTip until you click on it, then it persists until you exit it. I also like how it is easily resizeable. I could make some very awesome instant reports in my Java application using this interactive ToolTip. I am guessing it supports adding JComponents too and acts as a container.
I played with the JCustomTooltip library by Prefuse but I like Eclipse's better as it's more elegant.
Can someone point to it in a library somewhere? I'll even look at the Eclipse GITHub project if it is easily extractable.
回答1:
First off, all the Eclipse code is based on SWT, you mention Swing which SWT is not compatible with.
Eclipse actually uses several different classes to do the various tooltips.
The easiest to use is org.eclipse.jface.window.ToolTip which can be added to most SWT controls. You provide a subclass which can use any SWT controls in the popup window. There is also DefaultToolTip which provides a simpler interface.
The hover windows you see in things like the Java editor use a much more elaborate mechanism provided by the Eclipse text editor support based on the ITextHover, ITextHoverExtension, IInformationControlCreator, and IInformationControl interfaces. Since they rely heavily on support code in the Eclipse text editor classes they can't easily be used outside of this environment.
来源:https://stackoverflow.com/questions/22214399/what-is-the-tooltip-library-that-eclipse-uses-when-hovering-over-variables