File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JavaFX and the fly likes How to control Tooltip visible time and duration before showing? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JavaFX
Bookmark "How to control Tooltip visible time and duration before showing?" Watch "How to control Tooltip visible time and duration before showing?" New topic
Author

How to control Tooltip visible time and duration before showing?

Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Hello!

One more question is how to tell javafx.scene.control.Tooltip to stay visible for longer time and
stay visible while mouse is inside tooltip.
How to control duration after which particular Tooltip is shown?

Thank you!


True person is moral, false is right!
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 489
    
    5
Unfortunately, its public API doesn't allow this. Using openjfx 2.2 source code, I worked out the below hack which uses private classes and fields to override the default durations.
If you're not comfortable with accessing private fields, then you can subclass Tooltip and roll your own code based on TooltipBehavior to start timers, hide the window, etc. In fact for your
requirement that it should be visible as long as mouse is hovering, you'll probably need to roll your own code anyway.
Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Thanks for great reply!

I already use javafx8.

I'll try to subclass Tooltip and see what can be overridden.

Your method is really good.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Karthik, from my experience with the Swing sources, tracking that down must have taken considerable effort. Have a cow!


luck, db
There are no new questions, but there may be new answers.
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 489
    
    5
Darryl Burke wrote:Karthik, from my experience with the Swing sources, tracking that down must have taken considerable effort. Have a cow!

Yay, my first cow! Thanks much!
Guy Erlich
Greenhorn

Joined: Oct 20, 2013
Posts: 1
I've actually managed to control the timeouts/delay of the tooltip by implementing the show and hide myself.

Instead of:


Try this:


The repositioning of the tooltip at bottom-right is crucial since if you show it right under the mouse, the onMouseExited function will be called since the node will lose focus.
This code shows and hides the tooltip immediately upon enter/exit.
If you want to add timeouts, you can simple call the show/hide within a timer.
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 489
    
    5
Guy, that's a really neat solution, bypassing Tooltip's inflexible design altogether! Thanks for posting and Welcome to Coderanch!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to control Tooltip visible time and duration before showing?
 
Similar Threads
Display the content of a variable without <h:outputText>?
Pop up a message
How to register for expand event of TreeItem with no children?
Making tooltip stay for a while.
Duration For H1B