如果在 JFrame 之外,Java 中的 ToolTip 会闪烁吗? [英] ToolTip flicker in Java if outside JFrame?

查看:32
本文介绍了如果在 JFrame 之外,Java 中的 ToolTip 会闪烁吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 Java 实现 ToolTip,以使用户能够更轻松地使用该产品.尽管位于 JFrame 边界并最终位于 JFrame 外部的工具提示开始闪烁".我已经尝试了很多方法(例如移动工具提示使其应该在 Jframe 内,控制绘画使其最终在 JFrame 内等等),但它不起作用.

I am implementing ToolTip in Java as to make users having an easier time to use the product. Though tooltip that are at the borders of the JFrame and ends up outside the JFrame starts to "flicker". I've tried lots of things (like moving the tooltip so it should be inside the Jframe, controlling the painting so it ends up within the JFrame and so on) though it doesn't work.

有没有人在该领域有任何专业知识,知道如何避免这个问题?

Anyone got any expertise within the field that know how to avoid this problem?

干杯,斯卡里翁

推荐答案

当工具提示显示在 JFrame 中时,Swing 不会创建浮动窗口,它只是在 JFrame 的图形上下文中绘制工具提示.这不会产生任何闪烁.另一方面,当工具提示在 JFrame 的边界之外时,它就变成了重量级:创建一个窗口来承载工具提示组件.出现工具提示窗口时出现闪烁.

When a tooltip is displayed in a JFrame, Swing does not create a floating window, it simply paints the tooltip in the graphic context of the JFrame. This does not generate any flickering. On the other hand, when a tooltip is outside the boundaries of the JFrame, it becomes heavyweight: a window is created to host the tooltip component. Flickering occurs when the tooltip window appears.

也许设置-Dsun.awt.noerasebackground=true"会有所帮助,因为它可以防止主机窗口的背景重绘一步.

Maybe setting "-Dsun.awt.noerasebackground=true" would help because it prevents one step of background repainting of the hosting window.

这篇关于如果在 JFrame 之外,Java 中的 ToolTip 会闪烁吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆