首页 > 代码库 > Java Swing
Java Swing
参考帖子http://chenchaobox.blog.163.com/blog/static/6043759020127845945569/
http://wenku.baidu.com/link?url=jyBThcv1-wXJHBFKS63u0xuL7wazlrgcPOKK1EVLxpqSHhmvZhpGGlnfIirk-rHczIzPV00P4pMVn_ljPGoI0xBgYj7r7ZX6ysvIERLM5Ta
BufferedImage ImageOne = new BufferedImage(width2, height2,
BufferedImage.TYPE_INT_RGB);
Graphics g = ImageOne.getGraphics();//
g.fillRect(0, 0,width2, height2);
g.setColor(Color.BLACK);
Font mFont = new Font("宋体", Font.PLAIN, 20);
g.setFont(mFont);
//String str = "添加文字测试";
FontMetrics fm = g.getFontMetrics(mFont);
int textWidth = fm.stringWidth(str); //计算文字的宽度
g.drawString(str,(600-textWidth)/2, 100); //文字居中显示
g.drawImage(image,(600-image.getWidth())/2 , 500, null);//将二维码画入大图片中
Java Swing