mac10.5的java采用的图形渲染方式变了

来源:互联网 发布:2018 上海楼市 知乎 编辑:程序博客网 时间:2024/05/10 03:14

mac10.5 的渲染方式不再用以前默认的quartz了,现在默认为sun2d,所以如果老的代码里面有关repaint如果很多的话,会很影响效率,造成高cpu占用率,导致某些UI不能正常显示.

 

解决问题的办法如下:
java -Dapple.awt.graphics.UseQuartz="true" yourApplication

System.setProperty("apple.awt.graphics.UseQuartz", "true");

 

When using setting these properties within your application (using System.setProperty ), make sure that it's one of the first statements made inside of your main method. Doing so sets the property before AWT is loaded, ensuring that it takes effect.

因为applet在启动之前就已经装载了awt组件,所以applet程序现在无法在代码中实现转变使用老的quartz,只能在java preference那里加参数设置-Dapple.awt.graphics.UseQuartz=true了,这点有的麻烦,不知道apple或是sun公司能不能解决.

 

详情参考apple公司的文档
 http://developer.apple.com/documentation/Java/Conceptual/JavaPropVMInfoRef/Articles/JavaSystemProperties.html
 http://lists.apple.com/archives/Java-dev/2007/Dec/msg00108.html