Java小程序,AWT刷新问题的Mac OS X 10.4 [英] Java Applet, AWT Refresh problem Mac OS X 10.4

查看:131
本文介绍了Java小程序,AWT刷新问题的Mac OS X 10.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在使用AWT Java小程序构建的。此applet让您从您的硬盘选择照片,并将其上传到服务器。小程序包括图片的滚动列表,它在Windows,Linux和Mac OS X 10.5的罚款。我们推出通过Java Web Start或网页中该applet。

We have a Java Applet built using AWT. This applet lets you select pictures from your hard drive and upload them to a server. The applet includes a scrollable list of pictures, which works fine in Windows, Linux and Mac OS X 10.5. We launch this applet via Java Web Start or within a web page.

我们的小程序不会在Mac OS X 10.4检点,无论爪哇(1.4或1.5)的版本。您可以在不正确的行为的截图,滚动时,在这里:

Our applet does not behave properly in Mac OS X 10.4, regardless of the version of Java (1.4 or 1.5). You can find a screenshot of the incorrect behaviour, when scrolling, here:

http://www.lavablast.com/tmp/ui_error.png

滚动图片结束重叠应用程序的页眉或页脚时,简单地说,有时。此行为不会在其他平台上发生。在Mac OS X 10.4,这表明滚动时,在不正确的位置的图片,这将不会如此糟糕,如果在该位置画图像后刷新屏幕。但是,它不会出现应用程序知道它画的错误,因此不会刷新。

Simply put, sometimes when scrolling the pictures end up overlapping the header or footer of the application. This behaviour does not occur on other platforms. On Mac OS X 10.4, it shows the pictures in the incorrect location when scrolling, which would not be so bad if it refreshed the screen after painting the image at that location. However, it does not appear that the application knows it painted it incorrectly and thus does not refresh.

如果窗口是最小化,调整大小,甚至移动,应用程序刷新,错误地定位元素消失和应用恢复正常。我花了相当长的一段时间,试图迫使背景图像的刷新失败。 (直接重新绘制图像,重新绘制了几个小组的孩子,等等)。因此,我要寻找任何提示,帮助我解决这个问题,在Mac OS X 10.4或在最坏的情况下,简单地模拟一个完整的小程序刷新。

If the window is minimized, resized or even moved, the application is refreshed and the incorrectly positioned elements vanish and the application resumes normally. I spent quite some time trying to force a refresh of the background image unsuccessfully. (the repaint the image directly, repaint all children of a few panels, etc. ) Thus, I am looking for any tips that would help me resolve this problem under Mac OS X 10.4 or, in the worst case, simply simulate a full applet refresh.

直到最近,一切都与Java兼容1.1但这在现在要求1.4几个地点发生变化。我不觉得自己创建的问题这些变化,我只是提供此作为额外信息。如果你有兴趣在滚动面板的实现细节,我会调查,但我假定这是一个共同的平台错误的解决方法哪些必须知道。

Until recently, everything was compatible with Java 1.1 but this has changed in a few locations which now require 1.4. I don't feel these changes created the issue, I am just providing this as extra information. If you are interested in implementation details of the scroll panel, I will investigate, but I am assuming this is a common platform bug for which workarounds must be known.

要复制的问题,打开下面的Java Web Start应用:
http://www.lavablast.com/tmp/opal-webstart.php.jnlp

To replicate the problem, open the following Java Web Start application: http://www.lavablast.com/tmp/opal-webstart.php.jnlp

选择包含大量图像的文件夹,并滚动播放。在某些时候(很快),你应该得到的刷新问题。

Select a folder containing lots of images and play with the scrollbar. At some point (fairly quickly), you should get the refresh problem.

编辑:我在这里遵循的第一条建议,并取代了我所有的控制该功能的背景图像与一个Swing当量和问题依然存在。 (另外,有我需要做的,做一个彻底的改变许多其他的修正)。任何其他的想法? code的简单一行强制完全刷新将是巨大的:)

I followed the first suggestion here and replaced all my controls that feature background images with a Swing equivalent and the issue is still there. (Plus, there are numerous other fixes I would need to do to do a complete change). Any other ideas? A simple one line of code that forces a full refresh would be great :)

EDIT2:主线程创建的面板和启动点¯x线程。使用观察者/通知模式,线程完成,并通知主控制,增加了一个小组到该页面。这是通过哪个,除非我错了,应该正确的线程上运行EventQueue.invokeLater完成。滚动即使没有额外的线程在运行(如在加载过程中)时,这个问题是在其最严重的。

The main thread creates the panels and launches X threads. Using an observer/notifier pattern, the threads complete and notify the main control, which adds a panel to the page. This is done via an EventQueue.invokeLater which, unless I am mistaken, should run on the right thread. The issue is at its most severe when scrolling even if no extra threads are running (as during the loading).

推荐答案

它看起来像混合轻量级(通常摆动)和重量级(AWT)组件连接在一起。移动到Swing则需要更换每一个最后的AWT组件Swing的等价物。(提示:避免进口java.awt中的*)

It does look like mixing lightweight (usually Swing) and heavyweight (AWT) components together. Moving to Swing you need to replace every last AWT component Swing equivalents (hint: avoid import java.awt.*).

线程常常为奇数的错误的潜在问题。 Swing组件必须始终在EDT使用(使用了java.awt.EventQueue.invokeLater )。 AWT是线程安全的理论,但在实践中没有 - 也限制使用的EDT

Threading is often a potential problem for odd bugs. Swing components must always be used on the EDT (use java.awt.EventQueue.invokeLater). AWT is thread-safe is theory, but not in practice - also restrict usage to the EDT.

这篇关于Java小程序,AWT刷新问题的Mac OS X 10.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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