Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Shortening default time of tool tip visibility  RSS feed

 
Brady Diggs
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all -

Can someone please elaborate on the proper usage of ToolTipManager's initialDelay, reshowDelay and dismissDelay?
The API is not very informative in my opinion, and I can't seem to find any decent examples how to manipulate these
to get what I want.

Basically all I want to do is make the tool tip invisible immediately when the cursor leaves the component. I've tried setting dismissDelay to 0
but that did not work.

Can someone please lend a bit of insight here?
Thanks so much in advance. I appreciate your time.

bd
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried setting dismissDelay to 0

Dismiss? Shouldn't it be initial?
 
Rob Camick
Ranch Hand
Posts: 2800
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically all I want to do is make the tool tip invisible immediately when the cursor leaves the component.


This is the default bahaviour for me.

The dismiss delay controls when the tooltip is dismissed while you are hovering over the same component.

If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://sscce.org], that demonstrates the incorrect behaviour.

Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
 
Brady Diggs
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maneesh...

Thanks for taking a look at this.
Dismiss? Shouldn't it be initial?

I tried playing with initial, but that only seems to affect when the tooltip shows,
not how long it hangs around after the cursor has left the component (which is what I want to
shorten).

A bit of detail: The component is a JTable. The cell renderer calls setTooltipText(). No problem there.
When I move the cursor off the cell (even off the container onto my desktop), the tooltip lingers for
4 seconds. I know this is the default time for the dismissDelay, but shortening it doesn't make the tooltip go away.
On the contrary, setting dismissDelay to 0 prevents the tooltip from showing at all. Shortening it to half (2000)
makes it go away after 2 seconds while the cursor is still on the cell.

What I want to do is have the tooltip show up at the default time. I also what it linger the default time unless
the cursor is moved off the component, in which case I want it to disappear immediately.

Make sense?
 
Brady Diggs
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying, Rob. I have been learning from your posts on Sun's Java
forum for years.

This is the default bahaviour for me.

Strangely enough, for buttons that are on the same panel that the JTable is
on, it is the default behavior for me too; the tooltip disappears immediately
when I move my cursor off the buttons. For some reason it doesn't act like
this for the table cell.

Perhaps there is something going on with the cell renderer that I missed.
I will take another look before wasting any more of you guys' time.
If all else fails, I will create a SSCCE and post it here.
Thanks again!



 
Brady Diggs
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see what's happening now. The table only has three rows, but is 10 * rowHeight tall.
When the cursor is on a row, the tooltip pops up, but when the cursor moves off the row,
the tooltip doesn't disappear. The reason is that it moves from the row, but stays in the
area with no rows and that's still part of the table. Thus, the tooltip manager that is managing
the table (not the row) is keeping the tooltip alive as it is still relevant. Which it is in this case.

Now what I need to do is either put a glasspane or some panel onto the empty part of the table,
or get the ToolTipManager to understand that it doesn't need to show the tooltip unless it is on a row.

Does anyone have a suggestion of the best way to do this?

Thanks in advance.
 
Rob Camick
Ranch Hand
Posts: 2800
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason is that it moves from the row, but stays in the area with no rows and that's still part of the table


And that is why a SSCCE should be posted with every question. Based on your verbal description of the problem we could not guess exactly how your problem was working.

You can try overriding the getToolTipText() method of JTable. If the mouse point is outside the bounds of the last visible row you should be able to return null, otherwise just invoke the super method.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!