public class CaptchaUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
char[] |
codeSequence |
| 构造器和说明 |
|---|
CaptchaUtil()
验证码相关,为数字、英文,其中不含0、O、1、I等容易混淆的字符
|
| 限定符和类型 | 方法和说明 |
|---|---|
BufferedImage |
createImage()
创建(生成)验证码图片
|
Color |
getBackgroundColor()
获取验证码图片的背景颜色
|
String |
getCode()
获取当前的验证码
|
int |
getCodeCount()
图片上显示验证码的个数,1到5之间
|
Font |
getFont()
验证码的字体
|
int |
getFontHeight()
验证码文字的高度,文字本身的高
|
int |
getHeight()
生成图片的高度
|
int |
getWidth()
生成图片的宽度
|
void |
setBackgroundColor(Color backgroundColor)
设置验证码图片的背景颜色
不设置默认为白色
Color.WHITE |
void |
setCode(String[] code)
设置当前的验证码,如果想让验证码显示汉字等,可自己传入要显示的字符串
|
void |
setCodeCount(int codeCount)
图片上显示验证码的个数,1到5之间
|
void |
setFont(Font font)
验证码的字体,默认使用:
Font font = new Font("Fixedsys", Font.BOLD, fontHeight);
|
void |
setFontHeight(int fontHeight)
验证码文字的高度,文字本身的高
|
void |
setHeight(int height)
生成图片的高度
|
void |
setWidth(int width)
生成图片的宽度
|
public int getWidth()
public void setWidth(int width)
width - 宽度,单位:像素 pxpublic int getHeight()
public void setHeight(int height)
height - 高度,单位:像素 pxpublic int getCodeCount()
public void setCodeCount(int codeCount)
codeCount - 验证码个数,限制1~5public int getFontHeight()
public void setFontHeight(int fontHeight)
fontHeight - 文字本身的高度,单位:像素 pxpublic Font getFont()
public void setFont(Font font)
Font font = new Font("Fixedsys", Font.BOLD, fontHeight);font - 字体public String getCode()
public void setCode(String[] code)
code - 绘制到图片上的验证码public void setBackgroundColor(Color backgroundColor)
不设置默认为白色 Color.WHITE
backgroundColor - 要设置的背景颜色public BufferedImage createImage()
Copyright © 2019. All rights reserved.