java 通过Color设置Font

 1         //文本颜色
 2         Paint paint = new Color(44, 67, 85);
 3         //文字样式
 4         Font f = new Font("仿宋", Font.PLAIN, 18);
 5         
 6         //将上面样式放入Map内
 7         HashMap<TextAttribute, Object> textAttributes = new HashMap<TextAttribute, Object>();
 8         textAttributes.put(TextAttribute.FONT, f);
 9         textAttributes.put(TextAttribute.BACKGROUND, paint);
10         
11         //新建拥有上面样式的文字
12         textArea.setFont(new Font(textAttributes));

猜你喜欢

转载自www.cnblogs.com/gulu-miao/p/12907718.html
今日推荐