This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Strange Tooltip Behaviour Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Strange Tooltip Behaviour" Watch "Strange Tooltip Behaviour" New topic
Author

Strange Tooltip Behaviour

Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

I am working with a desktop application. I have got JButtons with letters from A to Z over which I want Tooltips to display the number of files classified under each letter. The file names are stored in a HashMap<String, List<String>>. The HashMap is instantiated and loaded with data before the JButtons are instantiated. Most of the time the tooltips display the corrected number of files, but occasionally they display zero number of files. On rare occasions there is no tooltip whatsoever!! I am using Jyloo's Synthetica Look And Feel but I doubt it has anything to do with this, because I did a test with the Nimbus Look And Feel provided by default with Java.
Haina Minawa
Ranch Hand

Joined: Oct 13, 2011
Posts: 119
Hi, it's better to post your code here. Then we will review it together.
Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190




Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

Forgot to mention. I am using NetBeans 7 under Java 7, update 1, on a very powerful top end computer.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

I don't think its a good idea to set a toolTipText in a mouseEntered event. For a toolTipText that might vary each time the component is moused over, I would override getToolTipText() instead.(Untested)


Shouldn't alphaButton be declared final in the code you posted?

edit You may or may not need to register the button with the ToolTipManager.


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

Joined: Jul 24, 2006
Posts: 190

Thanks Darryl. My JButton IS declared final in reality. I took the keyword out to make for faster reading on this forum. I will see about your advice. Thanks.
Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

Something like this, that works well, but I hope consistently.

Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Why do you feel the need to override the overload that takes a MouseEvent parameter, and why do you test e.getSource()?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Strange Tooltip Behaviour
 
Similar Threads
Adding Tooltip to JTable header
Creating ToolTips in JSTL code?
'title' attribute in Select box in relation to tooltip display
No mnemonic displayed in tooltip?
Multiline Tooltip