在Swing Java应用程序中正确显示转义字符作为工具提示的方法。

huangapple 未分类评论45阅读模式
英文:

Right way to display escape characters as tooltip in swing java application

问题

我正在使用setToolTipText方法在我的Java应用程序中设置工具提示文本。

jTextField1.setToolTipText("<html>" + "Line One" + "<br>" + "Line 2" + "</html>");

这在没有转义字符的情况下工作正常。但是,如果文本中有\b这个转义字符,工具提示中会显示一个小框。

应该如何正确地将这个\b显示为工具提示中的原始文本?

英文:

I am using setToolTipText method to set the tooltip text in my java application

jTextField1.setToolTipText(&quot;&lt;html&gt;&quot; + &quot;Line One&quot; +&quot;&lt;br&gt;&quot; + &quot;Line 2&quot; + &quot;&lt;/html&gt;&quot;);

This works fine unless a escape character comes in. Lets say if '\b' it present in the text, a small box is displayed in the tooltip.

What would be the right way to display this '\b' as is in the tooltip ?

huangapple
  • 本文由 发表于 2020年4月9日 01:29:15
  • 转载请务必保留本文链接:https://java.coder-hub.com/61106516.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定