Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty tooltips showing on screen #134

Closed
Nibby opened this issue Jul 27, 2020 · 5 comments
Closed

Empty tooltips showing on screen #134

Nibby opened this issue Jul 27, 2020 · 5 comments
Milestone

Comments

@Nibby
Copy link

Nibby commented Jul 27, 2020

When a component has an empty tooltip set, an empty tooltip bubble is drawn. For example:

JButton c = new JButton("Tooltip Test");
c.setToolTipText("");

Screen Shot 2020-07-28 at 11 44 52 AM

Setting the tooltip text to null disables this. This is quite different form other LaFs, where an empty tooltip is not shown.

@Poivin
Copy link

Poivin commented Jul 29, 2020

Yes i noticed that too. in my app i have tooltips with empty string inside and they were invisible before using flatLAF.

@DevCharly
Copy link
Collaborator

Thx for reporting. I agree that is does not make any sense to show empty tips. This is now fixed in master branch.

But this is actually a problem in Swing because it always creates a JToolTip as soon as JComponent.getToolTipText() != null.
(see https://github.com/openjdk/jdk/blob/bcff4990ad9db20d11c59841a409717118645a65/src/java.desktop/share/classes/javax/swing/ToolTipManager.java#L691-L694). So the only chance to "hide" the empty tooltip was setting its preferred size to 0,0.

I wonder what LaFs you're using that do not show empty tips. I tried Metal, Nimbus, Substance, Windows and Mac L&F and all showed empty tips...

@DevCharly DevCharly added this to the 0.39 milestone Jul 29, 2020
@Poivin
Copy link

Poivin commented Jul 29, 2020

Thx DevCharly!
I used Motif LaF and juste verified it again with the same code.
Edit : maybe somewhere in my hmi framework i have a setPreferredSize when using motif LaF...

@DevCharly
Copy link
Collaborator

@Poivin maybe you did not notice it because is is a small dot hidden by the mouse pointer. Move the mouse slightly to the right and you probably see it (Java 8):

grafik

Windows LaF (Java 8):
grafik

In Java 14 the empty tips are much larger and not hidden by the mouse pointer:
grafik
grafik

@DevCharly
Copy link
Collaborator

So generally I would recommend using null for toolTipText instead of empty strings 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants