怎样设定java.awt.Color的颜色java.awt.Font的字体(急在线等) 我想在图片上写字,我想自己设定它的颜色用RBG来确定:譬如 #FFB340 这种颜色;字体就定义中文的字体,譬如:棣书、楷体、宋体等字体?怎样可以设定??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.Color;import java.awt.Font;import java.awt.Graphics2D;import java.awt.image.BufferedImage;import javax.swing.ImageIcon;import javax.swing.JFrame;import javax.swing.JLabel;public class Test extends JFrame { public Test() { super("Test"); BufferedImage img = new BufferedImage(200, 100, BufferedImage.TYPE_INT_BGR); Graphics2D g2d = img.createGraphics(); g2d.setColor(new Color(255, 179, 64)); // #FFB340 -> R:255 G:179 B:64 g2d.setFont(new Font("黑体", 0, 20)); g2d.drawString("要写的文字", 50, 50); this.getContentPane().add(new JLabel(new ImageIcon(img))); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(300, 200); this.setVisible(true); } public static void main(String[] arg) { new Test(); }} 我知道这样可以设字体!! 我想要其他字体的样式怎样设!譬如象photoshop里面的字体!! mq612(五斗米)正解其它的字体呀,没办法,楼主不要想着象photoshop里用字体那么方便了,再不只能做一个字体列表了。 怎样将字符窜输入到特定txt文件中? antlr 实现while循环语句 java模拟登陆问题,期待明白人给讲解一下 关于while()循环的问题 求破坏本机的java代码 QQ群里的树结构怎么用JTree来实现? 如何将CVS的diff结果输出到文件? 各位大哥,大姐:救救小弟我吧,不然中秋之夜我就要加班了!!! 沙鸥的问题,记在账上 又到年终了,祝兄弟们万事如意,多拿奖金。开始散分..... 怎么关闭socket服务端的死循环! 字体的选择问题
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;public class Test extends JFrame { public Test() {
super("Test");
BufferedImage img = new BufferedImage(200, 100, BufferedImage.TYPE_INT_BGR);
Graphics2D g2d = img.createGraphics();
g2d.setColor(new Color(255, 179, 64)); // #FFB340 -> R:255 G:179 B:64
g2d.setFont(new Font("黑体", 0, 20));
g2d.drawString("要写的文字", 50, 50);
this.getContentPane().add(new JLabel(new ImageIcon(img)));
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(300, 200);
this.setVisible(true);
} public static void main(String[] arg) {
new Test();
}}
譬如象photoshop里面的字体!!
其它的字体呀,没办法,楼主不要想着象photoshop里用字体那么方便了,再不只能做一个字体列表了。