Tooltip in swing

一个人想着一个人 提交于 2019-12-12 13:25:54

问题


I made to tool tip for comportment in swing using some html tags

_graph.setToolTipText("<html><div style=\"width: 300px; height: 100px;" 
   +  " overflow: auto; border: 0;<p style=\"padding:2 5 2 5;\"></div>Please Wait...");

Here _graph is object of component. Problem is, if data is exceeds I need to scroll but it is not happening.please anyone suggest me to make scrollbar.


回答1:


Default tooltips are very basic: simply a lable-like component, even limited to text-only (except html). As I already mentioned, the way to more fancy tooltips is to extend JTooltip and let your graph component return that custom tooltip in createTooltip. An example and some pitfalls were recently discussed over at OTN




回答2:


I do not know how to create a tooltip containing a scrollbar, but I can think of several reasons why you should reconsider whether you want this.

  1. I do not know any application which has a tooltip containing a scrollbar, so no user is going to expect that.
  2. A tooltip is by definition a small "hover box" with information about the item being hovered over. How do you combine small with the fact you need a scrollbar in it ?
  3. Have you encountered a tooltip where you could click on some text and which would show more information ? How many times did you had to try with your mouse to navigate to the link, without having the tooltip to disappear ? That is not user-friendly. A scrollbar will have the same problem.

So my advise: rethink your UI design. Judging from the text of your tooltip in the question, I would guess you need some sort of overlay displaying a "Please wait" message.



来源:https://stackoverflow.com/questions/8834994/tooltip-in-swing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!