本文介绍了如何使JTextPane绘制抗锯齿字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在swing应用程序中,我使用 Graphics.drawString()使用自定义 JComponent 呈现文本。这是一个示例:



在同一个应用程序中,我使用 JTextPane 渲染文本。这是一个示例:

in the a swing app i'm rendering text with a custom JComponent, using Graphics.drawString(). here is a sample:
aa text http://img525.imageshack.us/img525/4928/drawstringsample.jpg
in that same app, i'm rendering text using a JTextPane. here is a sample:
alt text http://img28.imageshack.us/img28/1134/jtextpanesample.jpg

你能注意到较低的样本有点'污迹'吗?好吧,我无法弄清楚如何使它看起来像上面的样本。

can you notice how the lower sample is a little 'smudged'? well, i can't figure out how to make it look like the upper sample.

谢谢,asaf: - )

thanks, asaf :-)

更新:


  • System.setProperty( awt.useSystemAAFontSettings,false)lcd也无效。

  • ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF) in paint()不是工作

  • putClientProperty( sun.swing.SwingUtilities2 .AA_TEXT_PROPERTY_KEY,Boolean.TRUE)给出 java.lang.ClassCastException:java.lang.Boolean不能强制转换为sun.swing.SwingUtilities2 $ AATextInfo

  • System.setProperty("awt.useSystemAAFontSettings","false") and "lcd" too aren't working.
  • ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF) in paint() isn't working
  • putClientProperty(sun.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY, Boolean.TRUE) gives java.lang.ClassCastException: java.lang.Boolean cannot be cast to sun.swing.SwingUtilities2$AATextInfo

推荐答案

putClientProperty(SwingUtilities2 .AA_TEXT_PROPERTY_KEY,null);

这篇关于如何使JTextPane绘制抗锯齿字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 13:08