2

When mouse enter on any button without toolTip, appears black dot (like a corner of tooltip). It is really odd and I don't know what to do with it :/ I generated my project by netbeans -> java desktop application. I never setted toolTipText in this buttons so they are default empty. Any idea?

edit: When I wrote that it's empty I mean that it's nothing in properties of JButton toolTip. Generated code:

lottery.setAction(actionMap.get("lotteryStart")); // NOI18N
lottery.setText(resourceMap.getString("lottery.text")); // NOI18N
lottery.setName("lottery"); // NOI18N

programView.properties:

lottery.text=Start
5

Don't use NetBeans to generate the code. That way you know what all the code does and can make changes when you have problems.

The default should be null not "" (the empty string).

Post your SSCCE that demonstrates the problem.

4
  • 1
    I don't think the problem is with netbeans generated code, but rather with the use of Swing App Framework here (supported by netbeans). Problem seems to be with SAF resource injection using "" instead of null for injecting tooltip when no resource is specified in the properties file. – jfpoilpret May 29 '11 at 21:09
  • 2
    add to camickr correct sugestion, Java Desktop Aplications Framework is based on Swing, there are some methods implemented, maybe some not, anyway check this Swing tuturials on download.oracle.com/javase/tutorial/uiswing/index.html and tons of examples for each of methods on java2s.com/Code/Java/Swing-Components/… and java2s.com/Code/Java/Swing-JFC/CatalogSwing-JFC.htm +1 – mKorbel May 29 '11 at 21:10
  • +1 that is the problem. Just to make it easy to find out for themselves for others who will wonder here I have added my answer with the code presenting all what you said here guys and the problem. – Boro May 29 '11 at 23:42
  • I added to all jButtons setToolTipText(null), and it works. Fortunately i have only 10 buttons so it's not a problem. – czy May 30 '11 at 7:22
2

I agree with @jfpoilpret the problem is not NetBeans related. The problem is the tooltip not being, as @camickr said, default, i.e. null. You must be setting it to "" empty String somewhere. Set it to null and the problem is sorted.

The sample code below presents the problem. One button has tooltip null (as println proves this is the default one) the other one has "" (empty String).

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class ToolTipTest
{
    public static void main(String[] args)
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {               
                JPanel p = new JPanel();
                JButton b1 = new JButton("My tooltip is null");
                System.out.println("default tooltip is b1.getToolTipText()="+b1.getToolTipText());
                b1.setToolTipText(null);
                p.add(b1);
                JButton b2 = new JButton("My tooltip is\"\"");
                b2.setToolTipText("");
                p.add(b2);
                JFrame f = new JFrame();
                f.setContentPane(p);
                f.setSize(400, 300);
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.setVisible(true);
            }
        });
    }
}
1
  • 1
    IIRC, there is also one way, directly in properties file, to set the tooltip to null, something like lottery.tooltipText={null}, although I can't remember the exact details for that. Anyway, this still looks like a bug in SAF resource injection, somehow. – jfpoilpret May 30 '11 at 8:43
0

This is old, but actually a netbeans issue, and should be fixed. Still, not fixed.

Netbeans keeps setting the tooltips to "" instead of null. Even if they are set to null in text, next time UI design of netbeans is opened, it sets them to "" again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.