验证码的小游戏
我相信大家在生活中,一定经常遇见验证码这个东西,那么小编今天教大家玩一个简单的,有趣的,验证码小游戏。
(注释也标上了,很仔细地哦)
代码如下:
package abc;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
import javax.swing.*;
public class games {
//!!!!!!!!!
public static void main(String[] args) throws FileNotFoundException, IOException {
//构造BufferedImage图像对象
//宽像素,高像素,色彩空间类型
BufferedImage image=new BufferedImage(80, 32, BufferedImage.TYPE_BYTE_BINARY);
//编辑图像
//获取绘图对象
Graphics g=image.getGraphics();
//设置字体颜色
g.setColor(Color.white);
//设置字体
g.setFont(new Font("SimSong",Font.ITALIC,20));