user1145474
user1145474

Reputation: 53

Tooltip in swing

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.

Upvotes: 4

Views: 3433

Answers (2)

kleopatra
kleopatra

Reputation: 51525

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

Upvotes: 7

Robin
Robin

Reputation: 36611

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.

Upvotes: 2

Related Questions