[英]java swing graphics2d drawstring not working
BufferedImage image=new BufferedImage(32,32,BufferedImage.TYPE_INT_ARGB);
Graphics2D g2=image.createGraphics();
g2.setBackground(Color.white);
g2.setColor(Color.BLACK);
g2.drawString("A",0,0);
ImageIO.write(image,"PNG",new File("1.png"));
It just giving me an empty white image.它只是给了我一个空的白色图像。 Why?为什么?
Try:尝试:
g2.drawString("A", 0, 16);
(0,0) is the upper left corner and the drawString coordinates are for the lower left point where you want to draw (0,0) 是左上角,drawString 坐标是左下角要绘制的点
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.