有没有一种方法可以在字符串上设置字体,然后使用图形绘制字符串?我知道您可以在Jlabels,Jtextfields和J-other组件上执行此操作,但是有办法只在字符串上执行此操作吗?谢谢你。
您可以使用属性字符串来实现,例如
Font font = new Font("LucidaSans", Font.PLAIN, 14);
AttributedString atString= new AttributedString("Example text string");
atString.addAttribute(TextAttribute.FONT, font);
graphic.drawString(atString.getIterator(),x,y);
干杯!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句