windows 损坏的 Java Swing 窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/870472/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Corrupted Java Swing Window
提问by Vincent
One of the users of a Java swing GUI program that I wrote is having an issue where the main swing window doesn't render to the screen properly and the GUI freezes up. Here's a comparison of the screenshot on his screen (top) and what is supposed to show up (bottom):
我编写的 Java Swing GUI 程序的一位用户遇到了一个问题,即主 Swing 窗口无法正确呈现到屏幕上并且 GUI 冻结。这是他屏幕上的屏幕截图(顶部)和应该显示的内容(底部)的比较:
alt text http://www.shapecollage.com/temp/SwingCorruption.jpg
替代文字 http://www.shapecollage.com/temp/SwingCorruption.jpg
He is running Windows XP SP3 with Java 1.6.0_13 and his graphics card is an ATI X1600 with a dual monitor set-up.
他运行的是带有 Java 1.6.0_13 的 Windows XP SP3,他的显卡是带有双显示器设置的 ATI X1600。
The program (if you would like to test for yourself) is at:
www.shapecollage.com/download.html
该程序(如果您想自己测试)位于:
www.shapecollage.com/download.html
I have several thousand users and no one else has reported this error and I have tested it thoroughly on Windows XP. Anything computational is done in a separate thread from that of the regular GUI thread and the program works on many other computers, so I don't think it's a problem with the program itself, but rather, something wrong with his particular set-up.
我有几千个用户,没有其他人报告过这个错误,我已经在 Windows XP 上对其进行了彻底的测试。任何计算都是在与常规 GUI 线程不同的线程中完成的,并且该程序可以在许多其他计算机上运行,所以我认为这不是程序本身的问题,而是他的特定设置有问题。
Has anyone seen this type of error before on a system or have any suggestions as to what might be wrong on this user's system that would cause such a problem?
有没有人以前在系统上看到过这种类型的错误,或者对这个用户的系统上可能会导致此类问题的错误有什么建议?
Thanks,
Vincent
谢谢,
文森特
采纳答案by Slavcho
We had a very similar problem, which was fixed by updating the graphics driver. The problem might come from the dual monitor setup leading to VRAM corruption, so your customer might try if it will work better with only a single monitor. While you might expect Java would not be very dependent on the hardware, our graphics-intensitive application always manages to BSOD when run through a particular projector type...
我们有一个非常相似的问题,通过更新图形驱动程序解决了这个问题。问题可能来自导致 VRAM 损坏的双显示器设置,因此您的客户可能会尝试使用单个显示器是否能更好地工作。虽然您可能认为 Java 不会非常依赖硬件,但我们的图形密集型应用程序在通过特定的投影仪类型运行时总是会遇到 BSOD...
回答by Joachim Sauer
Maybe there's a problematic interaction between Java and the graphics driver and/or graphics hardware.
也许 Java 与图形驱动程序和/或图形硬件之间存在有问题的交互。
There are several flags that can influence how Java draws to the screen.
You might want to try to start the applications with any of those flags:
您可能想尝试使用以下任一标志启动应用程序:
-Dsun.java2d.opengl=true
-Dsun.java2d.d3d=false
-Dsun.java2d.noddraw=true
-Dsun.java2d.opengl=true
-Dsun.java2d.d3d=false
-Dsun.java2d.noddraw=true
Those flags toggle the OpenGL pipeline, turn of using Direct3D and disable use of DirectDraw respectively.
这些标志分别切换 OpenGL 管道、关闭使用 Direct3D 和禁用 DirectDraw。
If any of those solves your problem, then you might consider filing a Bug with sun, because then it's probably not the applications that's at fault here.
如果其中任何一个解决了您的问题,那么您可能会考虑向 sun 提交错误,因为这可能不是应用程序的问题。
回答by Michael Borgwardt
I haven't seen that particular type of corrupted graphics, but I have seen Java graphics problems on Windows disappear when the hardware acceleration in the extended display control panel is reduced.
我还没有看到那种特定类型的损坏图形,但我看到当扩展显示控制面板中的硬件加速降低时,Windows 上的 Java 图形问题就会消失。
回答by John Gardner
I have seen corrupted graphics like that, but never in java. The places i've seen it were in windows draw/etc code, and the tiling and snow look generally indicated something like telling the image draw code that you were going to draw an image of a certain size and bit depth, but then filling the image buffer with a different bit depth. like filling the byte array with data from an integer RGBA source and putting it into an integer RGB destination?
我见过这样损坏的图形,但从未在 java 中见过。我见过它的地方是在 windows draw/etc 代码中,平铺和雪景通常表明类似于告诉图像绘制代码您将绘制特定大小和位深度的图像,然后填充具有不同位深度的图像缓冲区。喜欢用来自整数 RGBA 源的数据填充字节数组并将其放入整数 RGB 目标?
but from the screen shot, the user looks like they're also running some other kind of app too, as there's an extra button by the minimize/maximize/close buttons, so some other third party application is modifying the window. Maybe that's messing with it?
但是从屏幕截图来看,用户似乎也在运行其他类型的应用程序,因为最小化/最大化/关闭按钮旁边有一个额外的按钮,所以其他一些第三方应用程序正在修改窗口。也许这是在搞砸它?
Otherwise i'd say driver issue. There's always some solutions like disabling d3d drawing or some other draw optimizations that the VM does automatically now, maybe that solves it?
否则我会说驱动程序问题。总是有一些解决方案,例如禁用 d3d 绘图或 VM 现在自动执行的其他一些绘图优化,也许可以解决它?
回答by Paul Tomblin
Swing isn't thread safe, so if you're doing the rendering anywhere other than the GUI thread, you can expect this sort of thing.
Swing 不是线程安全的,所以如果您在 GUI 线程以外的任何地方进行渲染,您可以期待这种事情。