Java3D Swing 工具提示出现卡顿问题

发布于 2024-11-14 12:26:03 字数 678 浏览 5 评论 0原文

我正在从事的一个 Java 项目在 Java3d 和 Swing 工具提示之间存在奇怪的冲突。

我们的程序设置为中心有一个 Java3D Canvas3D,周围是 Swing JComponent(按钮、滑块、文本框等)。键盘和鼠标用于在 3D 世界中移动,按钮允许进行其他操作。

问题是,每当 Swing 组件的工具提示延伸到我们的窗口(JFrame)之外时,Java3D 中的移动就会变得缓慢,并且出现严重的卡顿问题。由于我们读到了有关挥杆中重量级/轻量级混合的所有问题,我们认为这可能是问题所在。

我们最初的解决方案是重写每个组件的 getToolTipLocation() 方法,以确保工具提示保留在我们的窗口内。这似乎大部分有效,但它把工具提示留在了奇怪的位置。此外,我们偶尔会在程序启动后和生成任何工具提示之前(每 20-30 次启动)遇到卡顿/速度变慢的问题。

然后昨天我发现了一种更奇怪的修复方法。只要工具提示的宽度为 151 像素或更大,它们就不会导致超出窗口的减速问题。任何宽度为 150 像素或更小的工具提示一旦离开窗口就会导致速度减慢/卡顿问题。通过在我们使用的每种类型的组件中重写 createToolTip (),我们可以调用 setPreferedSize() 并确保所有工具提示的宽度均为 151 像素。当然,这种解决方法的问题是所有工具提示要么有大量空白,要么被截断。

有谁知道什么可能导致这种奇怪的行为以及我可以尝试解决它吗?

A Java project I am working on is having a bizarre conflict between Java3d and Swing tooltips.

Our program is setup with a Java3D Canvas3D in the center surrounded by Swing JComponents (buttons, sliders, text boxes, and the like). The keyboard and mouse are used to move around the 3d world and the buttons allow other manipulations.

The problem is that whenever a tool tip from the Swing components extends outside our window (a JFrame), the movement in Java3D slows to a crawl and has major stuttering issues. Because of all the problems we have read about regarding heavyweight/lightweight mixing in swing, we assumed that was likely to be the issue.

Our original solution was to override each components getToolTipLocation() method to ensure the tool-tips stay inside our window. This seemed to mostly work, but it left the tooltips in odd locations. In addition, we occasionally get the stuttering/slow down issue as soon as the program launches and before any tooltips have been generated (every 20-30 launches).

Then yesterday I discovered an ever stranger way of fixing it. As long as the tool-tips are 151 pixels wide or greater, they don't cause the slowdown problem going outside the window. Any tooltip that is 150 pixels wide or less causes our slowdown/stuttering issue as soon as it leaves the window. By overriding createToolTip () in each type of component we use, we can call setPreferedSize() and ensure that all the tool tips are 151 pixels wide. The problems with this workaround, of course, is that all the tooltips have either lots of blank space or are truncated.

Does anyone have any idea what could be causing this odd behavior and what I could try to fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

維他命╮ 2024-11-21 12:26:03

为了解决重量级/轻量级混合问题,我总是选择以下有关 JPopupMenu 和 ToolTip 的设置:

import javax.swing.JPopupMenu;
import javax.swing.ToolTipManager;

ToolTipManager ttManager = ToolTipManager.sharedInstance();
ttManager.setEnabled(true);
ttManager.setLightWeightPopupEnabled(false);

JPopupMenu.setDefaultLightWeightPopupEnabled(false);

您也实现了这个吗?或者有帮助吗?

八月,InteractiveMesh

To solve heavyweight/lightweight mixing issues I always choose following settings concerning JPopupMenu and ToolTip:

import javax.swing.JPopupMenu;
import javax.swing.ToolTipManager;

ToolTipManager ttManager = ToolTipManager.sharedInstance();
ttManager.setEnabled(true);
ttManager.setLightWeightPopupEnabled(false);

JPopupMenu.setDefaultLightWeightPopupEnabled(false);

Have you implemented this as well? Or does it help?

August, InteractiveMesh

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文